-
-
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
docs: add HydrateFallback to the data-loading doc #12601
base: main
Are you sure you want to change the base?
Conversation
|
@@ -9,6 +9,8 @@ Data is provided to the route component from `loader` and `clientLoader`. | |||
|
|||
Loader data is automatically serialized from loaders and deserialized in components. In addition to primitive values like strings and numbers, loaders can return promises, maps, sets, dates and more. | |||
|
|||
The type for the `loaderData` prop is [automatically generated][type-safety]. | |||
|
|||
## Client Data Loading | |||
|
|||
`clientLoader` is used to fetch data on the client. This is useful for pages or full projects that you'd prefer to fetch data from the browser only. |
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 might introduce HydrateFallback
here since it can/should be used for this scenario where you have only a clientLoader
, and no loader
. In that scenario, clientLoader.hydrate
defaults to true because we have to run it on hydration if we have no loaderData
from the server.
Then below you can mention:
- When you provide a server
loader
in addition to aclientLoader
, we can render the during SSR using the server loader data - If if we do not want to render the route with only server loaderData, then set
clientLoader.hydrate=true
to run on hydration and provide aHydrateFallback
to render untilclientLoader
completes
const serverData = await serverLoader(); | ||
const res = await fetch(`/api/products/${params.pid}`); |
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 feels redundant? In remix we showed off the common use cases in a dedicated page so maybe we pick what we think is the most common (presumably "skip the hop") and inline it into this doc but then we copy over the Remix doc and link off to it for advanced use cases?
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.
Yeah agreed. Initially I was combining that doc with the full stack data doc we had, but then realize we already had this doc
I think a dedicated advanced data loading explanation or how-to is a good idea. I’ll try to put something together, even if it’s just a starting point we can improve upon later
We didn't really have any info on
HydrateFallback
or whatclientLoader.hydrate = true
does, so hopefully this helps fill in the gap