How can we lazy load route data using @solidjs/router ?
When using this pattern:
Here, the
User
component is lazy loaded but what about the UserData
?
Is there a way to do that?14 Replies
Are you making use of the useParams hook in the User component?
If so I would suggest fetching the user data within the User component using the :id parameter gotten using useParams
nope im not
I would suggest going that route if you would like to keep everything segregated to happen only when requested
Like so
yeah that was what i was doing before using ...data.ts
but i was wondering if there was a solution with route data
Oh Ok. I haven't used route data much. Have you tried using the lazy function? The same way you did with the User component
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
in what way does this lose SSR
just want to say that im using just SolidJS without any SSR stuff, it's just a SPA
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
what
this might work but well that is just a createRessource for another createRessource so ugh -
wanted to use route data to make my code look simpler ðŸ˜
What he meant is to lazy load the function you are using for the createResource
e.g
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
by doing this, I'll get the module in the useRouteData
so
so to access the data returned i have to
((user()).default())()