-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Ensure consistent component tree for useId #9805
Conversation
🦋 Changeset detectedLatest commit: 190c776 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -119,22 +119,18 @@ export function StaticRouterProvider({ | |||
|
|||
return ( | |||
<> | |||
<DataStaticRouterContext.Provider value={context}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This outer <DataStaticRouterContext>
is removed in favor of a staticContext
field on dataRouterContext
. Easiest to see with whitespace hidden 😉
</DataRouterStateContext.Provider> | ||
</DataRouterContext.Provider> | ||
{null} | ||
</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the structure generated by RouterProvider
matches that generated by StaticRouterProvider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused why we need the null
since the docs indicate that only the parent path matters, and our useId
calls would be down inside <Routes/>
. But without the null I constantly ran into hydration mismatches 😕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind filing a question / bug over on the react repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems expected - it might just be a docs issue: facebook/react#22733. Added my own comment in there suggesting a docs update
if (__DEV__) { | ||
DataStaticRouterContext.displayName = "DataStaticRouterContext"; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an UNSAFE
export so ok to remove and add onto DataRouterContext
(which is also exported as UNSAFE
)
dataRouterContext.staticContext && | ||
match.route.errorElement | ||
) { | ||
dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only reason we need staticContext
around in the component tree - so we can track render depth to bubble SSR render errors
@@ -98,6 +97,7 @@ export function StaticRouterProvider({ | |||
router, | |||
navigator: getStatelessNavigator(), | |||
static: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we get rid of the static prop in favor of the existence of the static context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite yet - we still need static
for non-data-routers doing SSR
Co-authored-by: Jacob Ebey <[email protected]>
We found a useId mismatch when testing Remix
1.10.0-pre.5
. It came down to 2 separate issues:<DataStaticRouterContext>
during SSR. This has now been collapsed into an optionalstaticContext
field on<DataRouterContext>
<script>
/null
inStaticRouterProvider
that were not reflected inRouterProvider