Repository navigation
Support for client side context - #12515
Conversation
🦋 Changeset detectedLatest commit: 2aa4152 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 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 |
| AwaitProps, | ||
| IndexRouteProps, | ||
| LayoutRouteProps, | ||
| MemoryRouterOpts, |
There was a problem hiding this comment.
Export this and DOMRouterOpts so they get picked up by typedoc
| return updates; | ||
| } | ||
|
|
||
| export interface MemoryRouterOpts { |
There was a problem hiding this comment.
Extracted to an interface so it gets it's own docs page and to align with DOMRouterOpts
| /** | ||
| * Router context singleton that will be passed to loader/action functions. | ||
| */ | ||
| context?: DefaultRouterContext; |
There was a problem hiding this comment.
This is the only new API:
let router = createMemoryRouter(routes, {
context: { user: getUser() }
});|
|
||
| interface AppLoadContext { | ||
| [key: string]: unknown; | ||
| } |
There was a problem hiding this comment.
No longer need this duped with the repo merge and we can import the actual one
| ); | ||
| } | ||
|
|
||
| // Patch in the Remix context to loaders/actions |
There was a problem hiding this comment.
No longer needed 🫡
| { request }: LoaderFunctionArgs, | ||
| singleFetch?: unknown | ||
| ) => | ||
| dataRoute.loader = (_: LoaderFunctionArgs, singleFetch?: unknown) => |
There was a problem hiding this comment.
request was unused here
| ); | ||
| let inFlightDataRoutes: AgnosticDataRouteObject[] | undefined; | ||
| let basename = init.basename || "/"; | ||
| let routerContext = typeof init.context !== "undefined" ? init.context : {}; |
There was a problem hiding this comment.
Default context to {} just like in Remix/SSR
| : findNearestBoundary(matches, actionMatch.route.id); | ||
|
|
||
| let context = await loadRouteData( | ||
| let handlerContext = await loadRouteData( |
There was a problem hiding this comment.
Rename for clarity:
handlerContext-> aStaticHandlerContextreturned fromstaticHandler.query()requestContext-> TheAppLoadContextused passed tostaticHandler.queryby Remix SSR todayrouterContext-> This newDefaultRouterContextused for SPAs since it's not tired to a request like the SSR use case
In shared code, requestContext becomes routerContext
| request: Request; | ||
| params: Params; | ||
| context?: Context; | ||
| context: Context; |
There was a problem hiding this comment.
No longer optional - still maintains a default type of any though
| manifest, | ||
| mapRouteProperties | ||
| mapRouteProperties, | ||
| routerContext |
There was a problem hiding this comment.
This is the core functional addition - the shared dataStrategy stuff already supports context for SSR, we just didn't used to pass anything for client side usages - now we do
| results = await callDataStrategyImpl( | ||
| dataStrategyImpl, | ||
| type, | ||
| state, |
There was a problem hiding this comment.
This param was unused
| manifest: RouteManifest, | ||
| mapRouteProperties: MapRoutePropertiesFunction, | ||
| requestContext?: unknown | ||
| routerContext: unknown |
There was a problem hiding this comment.
No longer optional since it's used in both SSR and SPA use cases
rossipedia
left a comment
There was a problem hiding this comment.
I know my review doesn't mean anything in a practical sense BUT HOT DAMN YES PLEASE
|
I would love this so much!!!! |
851f227 to
2a92d5e
Compare
21251ff to
2aa4152
Compare
No description provided.