Allow for state params in pushState
See original GitHub issueStarting to use your library with Svelte 3. This is either a question or feature request…
I see the pushState events are basically using the state
param for the uri. This removes ability to history.pushState(someRouteState, ...)
right?
Seems like it would be nice to have pushState state
param, say, default to null but be available to use… when caching some route data like here:
https://twitter.com/ryanflorence/status/1111272046372093953
None of the other generic routers seem to handle this well OR they don’t handle search params well or something. Yours is best so far and small. But having state available would be nice.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
update parameters in URL with history.pushState()
Show activity on this post. I am using history. pushState to append few params to current page URL after making an AJAX call...
Read more >History.pushState() - Web APIs | MDN
Parameters. state. The state object is a JavaScript object which is associated with the new history entry created by pushState() .
Read more >Working with history, pushState and replaceState in Javascript
This example will add a new entry into our history, with the state of an object carrying the user's id, the new title...
Read more >JavaScript History pushState
pushState () method allows you to add an entry to the web browser's session history stack. Here's the syntax of the pushState() method:...
Read more >History.pushState() - Web APIs
pushState () method adds a state to the browser's session history stack. Syntax. history.pushState( state , title [, url ]). Parameters. state ......
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
No worries 👍… I think the canonical example is just a slight optimization when routing to sub route where you have the data already, which then it’s just the initial state (state || undefined), so not too complex in that case and consistent on refresh.
Other than that, I could see wanting to stay consistent with native API, but it’s not super necessary to have I guess.
On Tue, May 7, 2019, 16:31 Luke Edwards notifications@github.com wrote:
Hey, thank you
I thought about this initially, but it’s a really unreliable thing to do. Problem is that if you’re not explicitly providing defaults and fallbacks on every single route (or every single time you read history state) then you will have faulty/undefined data.
For example, / to /about to /blog/hello-world
If that’s the path you plan for, should be fine. But if user enters your app AT /about or AT any blog post, you’d have to manually define the fallback data you expected to have, or suffer errors.
You basically end up coding the app twice
IMO it’s much better to just rely on the URL since that’s common to all entry points and all rendering contexts, including server-side.