renderLoader
- a loader than runs on the render target
#10599
jakearchibald
started this conversation in
Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
A couple of times I've ran into issues where:
An example is cases where one of 100s of components is needed depending on state such as URL or cookies. Doing the work async within the component tree is not acceptable, because that would require a suspense boundary, and therefore wouldn't server render.
Duplicating code between the
loader
andclientLoader
doesn't work, because the tree is hydrated before theclientLoader
data is available. Plus you need to use hacks to prevent the unserialisable data being serialised in theloader
(eg mark it as notenumerable
.I feel like I need a loader that runs where the rendering will be performed.
Here's how I understand loading happens now, assuming a fresh tab load:
loader
runs on the serverloader
data is deserialised on the clientloader
dataclientLoader
withhydrate = true
runs on the client.clientLoader
data.And here's what I'm looking for:
loader
runs on the serverrenderLoader
runs on the serverrenderLoader
data. But only theloader
data is serialised.loader
data is deserialised on the clientrenderLoader
runs on the clientrenderLoader
dataclientLoader
withhydrate = true
runs on the client.clientLoader
data.In cases where it's an SPA navigation:
loader
dataloader
runs on the server, and the data is returnedloader
data is deserialised on the clientrenderLoader
runs on the clientclientLoader
withhydrate = true
runs on the client.clientLoader
data.I think it would be rare to use
renderLoader
andclientLoader
together, but I wanted to be clear about the ordering.An example of a render loader:
For the API above, I'm following the patterns of the
clientLoader
. Hopefully this demonstrates the use-case, asMainComponent
need to be there in the server render, and having all possibilities of./components/${loaderData.componentToLoad}/index.tsx
in the route bundle would be unacceptable.serverLoader
inClientLoaderFunctionArgs
would need to be renamed, as it would be returning the result of therenderLoader
if one is present, not the "server loader". Maybe a name could be found that works for both therenderLoader
andclientLoader
.loaderData
might be good enough?Beta Was this translation helpful? Give feedback.
All reactions