-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Add routes prop to HydratedRouter #11693
Conversation
🦋 Changeset detectedLatest commit: 5a1aefa The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 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 |
} catch (e) { | ||
propRoutesError = e; | ||
} | ||
} |
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.
First, add the prop.routes
to our routes
generated from the manifest
before we create the router
@@ -39,7 +39,7 @@ export interface EntryRoute extends Route { | |||
hasErrorBoundary: boolean; | |||
imports?: string[]; | |||
css?: string[]; | |||
module: string; | |||
module?: string; // Undefined for <HydratedRouter routes> |
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 needs to be optional for routes coming from <HydratedRouter routes>
so had to make some other minor changes to existing code to account for that
a746f7a
to
466a58c
Compare
if (ssrInfo && propRoutes) { | ||
let rootDataRoute = router.routes[0]; | ||
for (let route of rootDataRoute.children || []) { | ||
addPropRoutesToRemix(ssrInfo, route as DataRouteObject, rootDataRoute.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.
Add the new routes to the Remix manifest
/routeModules
structures as if they came from the server - they just won't have a route.module
if (matchedPropRoute) { | ||
for (let [routeId, error] of Object.entries(hydrationData.errors)) { | ||
if (isRouteErrorResponse(error) && error.status === 404) { | ||
delete hydrationData.errors[routeId]; |
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.
Wipe out any SSR'd 404s if we now match our new client routes - we will have a hydration error/flicker but it will recover with the client render
No longer needed #11652 (comment) |
Replaces remix-run/remix#9062 against v7
Allows you to provide client-side only routes to
<HydratedRouter>
to ease the migration from a v6RouterProvider
SPA to the Vite plugin SPA Mode