Initialstate is not updated for subsequent routes
See original GitHub issueTry the example below and for all paths you will get the same initialstate. Seems it only uses the first one. I would expect for every page initialstate.data
to be the path of that page.
// src/main.ts
// ...
export const createApp = ViteSSG(
App,
{ routes },
({ app, router, routes, isClient, initialState, routePath }) => {
// ...
if (import.meta.env.SSR) {
initialState.data = routePath
} else {
console.log(initialState.data) // => { routePath :"/" }
}
// ...
}
)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:38 (18 by maintainers)
Top Results From Across the Web
NextJS initial state is not updating when routing to same page ...
On subsequent page renders (client side routing), NextJS executes it on the client, but this means that data is not available before page ......
Read more >NextJS initial state is not updating when routing to same page ...
On subsequent page renders (client side routing), NextJS executes it on the client, but this means that data is not available before page...
Read more >com.fulcrologic.fulcro.routing.legacy-ui-routers - cljdoc
If any of the routers are dynamic, then this mutation will check to see if the target routes are loaded. If any are...
Read more >Initial State Simulations - Innovyze
When a simulation is carried out, the state of an InfoWorks network at a specified date and time may be saved for use...
Read more >Handling user authentication with Redux Toolkit
This logic can be extracted into a single ProtectedRoute component, and we are going to create that next. Protected routes with React Router....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@husayt just clone this repo and change the lines 91 and 120: on former remove the inicial state and later add the initial state, on build you will have on each html page its own state, just modify the router example with your logic
@userquin if this issue is fixed I expect the code above to just work. That would make vite-SSG so much more powerful and flexible