T
TanStack16mo ago
spiritual-aqua

useRouteContext initially undefined

Hi, I have a custom ssr project. I'm using the useRouterContext in my react component and observing the following. 1. When rendered on server its defined. 2. When client side navigating to the page with the component, its defined. 3. When loading the page, i see that the initial correct html, but instantly get on error in browser due to context being undefined. I do not have any hydration warnings or errors. I remember back in the days when working with react router that I had to wait for it to be initialized or something. Anyone has an idea of what might be wrong?
3 Replies
spiritual-aqua
spiritual-aquaOP16mo ago
It's can be reproduced in the "basic-ssr-file-based" example. If you go from "home" to "post" in browser, the context is defined. If you reload the page while standing on "post" page, it's undefined.
No description
conscious-sapphire
conscious-sapphire16mo ago
can you please create a github issue so it can be tracked?
spiritual-aqua
spiritual-aquaOP16mo ago
GitHub
useRouteContext initially undefined · Issue #1635 · TanStack/router
Describe the bug When loading the page, 'useRouteContext' is undefined. When client side navigating to the page, it's defined. Your Example Website or App https://tanstack.com/router/la...

Did you find this page helpful?