Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flight] Implement useId hook #24172

Merged
merged 6 commits into from May 31, 2022
Merged

[Flight] Implement useId hook #24172

merged 6 commits into from May 31, 2022

Commits on May 31, 2022

  1. Implements useId hook for Flight server.

    The approach for ids for Flight is different from Fizz/Client where there is a need for determinancy. Flight rendered elements will not be rendered on the client and as such the ids generated in a request only need to be unique. However since FLight does support refetching subtrees it is possible a client will need to patch up a part of the tree rather than replacing the entire thing so it is not safe to use a simple incrementing counter. To solve for this we allow the caller to specify a prefix. On an initial fetch it is likely this will be empty but on refetches or subtrees we expect to have a client `useId` provide the prefix since it will guaranteed be unique for that subtree and thus for the entire tree. It is also possible that we will automatically provide prefixes based on a client/Fizz useId on refetches
    
    in addition to the core change I also modified the structure of options for renderToReadableStream where `onError`, `context`, and the new `identifierPrefix` are properties of an Options object argument to avoid the clumsiness of a growing list of optional function arguments.
    gnoff committed May 31, 2022
    Copy the full SHA
    1b7aaab View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    baa298b View commit details
    Browse the repository at this point in the history
  3. Copy the full SHA
    b224f07 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    2c4a074 View commit details
    Browse the repository at this point in the history
  5. Add a test demonstrating that there is no warning when double renderi…

    …ng on the client a server component that used useId
    gnoff committed May 31, 2022
    Copy the full SHA
    aa490a3 View commit details
    Browse the repository at this point in the history
  6. lints and gates

    gnoff committed May 31, 2022
    Copy the full SHA
    d72d44d View commit details
    Browse the repository at this point in the history