You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
It looks like this library does not expose a function to get the matched route (only the useRoutes hook). This would be quite useful for server side rendering.
I'll take Next.js as an example. What the framework does is:
match the route on request
await the resolved page module (it's a Promise because of code-splitting)
only then render React to string
So if Next.js was using this library, it would need a way to get the resolved value (usually retrieved from useRoutes), then await that value and only then render the JSX (and pass that awaited value as a prop).
If it's still unclear what I'm proposing here, the routes definition in Next.js when converted to this library could look something like this:
The reason why this solution is needed is because Suspense is not currently supported on the server, and awaiting the page module is the only viable way of lazy loading the page.
I would imagine the API could be:
setPath(path);constroute=getRoute({'/': ()=>import('./Index.jsx'),'/home': ()=>import('./Home.jsx')});// then make use of the valueconsthtml=ReactDOMServer.renderToString(<AppPage={awaitroute}/>);
Let me know if this makes sense and if it's in the scope of the library.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It looks like this library does not expose a function to get the matched route (only the
useRoutes
hook). This would be quite useful for server side rendering.I'll take Next.js as an example. What the framework does is:
So if Next.js was using this library, it would need a way to get the resolved value (usually retrieved from
useRoutes
), then await that value and only then render the JSX (and pass that awaited value as a prop).If it's still unclear what I'm proposing here, the routes definition in Next.js when converted to this library could look something like this:
The reason why this solution is needed is because Suspense is not currently supported on the server, and awaiting the page module is the only viable way of lazy loading the page.
I would imagine the API could be:
Let me know if this makes sense and if it's in the scope of the library.
The text was updated successfully, but these errors were encountered: