Skip to content

Conversation

grahammendick
Copy link
Owner

On the people list edit the route in stateNavigator.tsx and the hyperlinks should all update but didn't. Vite HMR creates a new stateNavigator and the NavigationHandler didn't handle it. It doesn't expect the stateNavigator prop to ever change. Updated NavigationHandler to change the navigation context when the prop changes and the HMR works and updates the hyperlinks.

However there is a Vite HMR bug that happens if edit the route a second time. Vite HMR calls the NavigationProvider with the latest url but the old stateNavigator. It throws trying to parse the latest url. Wrapped the navigateLink call in a try/catch and this works because eventually Vite HMR calls with the latest stateNavigator. Will raise on Vite and see what they say.

When vite hmr happens the state navigator can change - if editing a route in the config, for example. So the NavigationHandler needs to rerender with the new state navigator. Will need to test if this actually works outside of hmr - will add unit tests and see
If edit the state navigator route config twice in a row then the 2nd time vite rerenders the NavigationProvider from scratch with the new url bug the old stateNavigator - only temporarily, it then renders it with the new stateNavigator. So caught the error and prevented SceneRSCView throwing when there's empty state context.
Copied files over from parcel
@grahammendick grahammendick merged commit 3db3137 into master Jul 31, 2025
@grahammendick grahammendick deleted the vite-hmr branch July 31, 2025 22:06
grahammendick added a commit that referenced this pull request Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant