Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useRouteContext initially undefined #1635

Open
InsideGH opened this issue May 19, 2024 · 3 comments
Open

useRouteContext initially undefined #1635

InsideGH opened this issue May 19, 2024 · 3 comments
Labels
bug Something isn't working ssr Everything around SSR the story

Comments

@InsideGH
Copy link

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/latest/docs/framework/react/examples/basic-ssr-file-based

Steps to Reproduce the Bug or Issue

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.

Screenshot from 2024-05-19 17-12-17

Expected behavior

useRouteContext being defined both during SSR load and Client side routing.

Screenshots or Videos

No response

Platform

Linux

Additional context

No response

@SeanCassiere
Copy link
Contributor

I've tested this using the "basic-ssr-file-based" in the sandbox below (with all the packages upgraded to latest). In the sandbox below, I was not able recreate the issue you described.

https://stackblitz.com/edit/github-djwvqx?file=src%2Froutes%2Fposts%2Findex.tsx

Please attach a minimal reproduction of the issue you facing with any steps required to replicate the scenario to observe the issue.

@SeanCassiere SeanCassiere added the information needed Further information is requested label May 20, 2024
@lithdew
Copy link
Contributor

lithdew commented May 20, 2024

@SeanCassiere was able to reproduce it in the sandbox you linked. Navigating to /posts and refreshing the page causes a hydration error and: PostsIndexComponent.context undefined

image

@SeanCassiere
Copy link
Contributor

SeanCassiere commented May 20, 2024

Reproduction steps:

  1. Open the stackblitz example and open the preview in a new tab.
  2. Directly visit /posts/.
  3. Observe the error message on the screen and in the console.
  4. Observe the hydration failure message in the console.

Edit: I haven't seen this behaviour on client-side rendering ONLY apps.

@SeanCassiere SeanCassiere added bug Something isn't working ssr Everything around SSR the story and removed information needed Further information is requested labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ssr Everything around SSR the story
Projects
None yet
Development

No branches or pull requests

3 participants