Replies: 1 comment
-
If the route has a So the moment you add a On SSR, your will get the server |
Beta Was this translation helpful? Give feedback.
-
If the route has a So the moment you add a On SSR, your will get the server |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As we play around with patterns for our application, we find ourselves wanting to use a mix of loader and clientLoader data. We're following the patterns around using both loaders. But we've noticed that if we augment the loader data with additional clientData, then we start getting types errors since loaderData becomes a union of the two loaders (makes sense).
In order to get around this, we find ourselves adding a isClientData boolean that's const true or false to each return so that we can discriminate the type union and access the values.
This seems like it might be a common scenario, and it would be nice and reduce boilerplate if the boolean and types were automatically added by react-router. Should also be a trivial amount of boilerplate + complexity, since the types are already figuring out and generating the union. If not, open to other suggestions on best ways to address that...maybe it just merits a brief sentence in the docs to help folks out! (Or maybe RR is opinionated and should never be augmenting data in clientLoaders)
Beta Was this translation helpful? Give feedback.
All reactions