TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
7.19k stars 486 forks source link

the `context` in the `onEnter` is callback on the Route definition returns `undefined` on first-load during runtime #1529

Open Zebeqo opened 2 weeks ago

Zebeqo commented 2 weeks ago

Describe the bug

When first loading, onEnter runs before loader and context in onEnter is always undefined.

Your Example Website or App

https://stackblitz.com/edit/github-h2bsvy

Steps to Reproduce the Bug or Issue

  1. The application loaded and the console output context from onEnter undefined and context from loader {test: 'abc'}
  2. Go to the /about page and back to /, the console output context from loader {test: 'abc'} and context from onEnter {test: 'abc'}

Expected behavior

The application loaded and the console output context from loader {test: 'abc'} and context from onEnter {test: 'abc'}

Screenshots or Videos

No response

Platform

Additional context

No response