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
Hi community,
my question is pretty straight forward. How do I migrate from the old static-location to the new SSR mode way of working when I need to detect redirects. I think I understand the migration but im just missing the 'record: true' part and where i can make it fit into the context.
Example: I used the old functionality in this way:
It's not possible at the moment unfortunately. The staticLocationHook has been deprecated because it stopped working when we switched to useSyncExternalStore. The new approach to use SSR is to use ssrPath prop. In theory, we could detect redirects when the page is rendered, but that will require us to perform redirects outside of useLayoutEffect (which doesn't fire on a server). I haven't researched the implications of calling setLocation directly in render though. Will it. Will it work with Suspense?
@molefrog the approach taken by react-router and other libraries (such as loadable-components) that need to track render attributes of a child during a SSR is to wrap their children in a context. The child component (in this case Redirect) would register with that context that it redirected to a given URL. That context state can then be read by users of Router to know if a redirect occurred.
Hi community,
my question is pretty straight forward. How do I migrate from the old static-location to the new SSR mode way of working when I need to detect redirects. I think I understand the migration but im just missing the 'record: true' part and where i can make it fit into the context.
Example: I used the old functionality in this way:
const location = staticLocationHook(req.originalUrl, { record: true });
And then i use it like
and also
Thank you in advanced
The text was updated successfully, but these errors were encountered: