Adding prev history to locationState on initial load?
See original GitHub issueI’d like to push some history (e.g. pathname) to the prev object on initial load of the page.
Is it possible to do this without using the Rudy-History package or do I need the createHistory function that returns an object in some proper form to connectRoutes?
Thanks for shedding a little light on this, it seems weird to require another package when what it looks like I’m trying to do is simply:
location: {
...location,
prev: {
...location.prev,
pathname: 'newpath'
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How do I clear location.state in react-router on page reload?
If you're using react hooks, you can use window.history directly to clear the state without triggering a rerender. This is better than using...
Read more >Using React with the History API - Pluralsight
React Router has a useHistory hook that provides a history interface that we can easily use for routing. Add buttons to these pages...
Read more >Programmatically Navigate Using React Router - Stack Abuse
In this guide, learn how to create routes, programmatically navigate, send and receive data using React Router in JavaScript, with practical ...
Read more >React Router - Using Location State for Custom UI Navigation
React Router - Using Location State for Custom UI Navigation ... Send us to the previous page history.push(redirectUrl) // i.e. "/posts".
Read more >History API - MDN Web Docs - Mozilla
Chrome Edge Firefox
History Full support. Chrome1. Toggle history Full support. Edge12. Toggle history Full sup...
back Full support. Chrome1. Toggle history Full support. Edge12....
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
I haven’t tried it, but my impression from reading the code is that this is supported in Rudy by using the history
reset
functionhttps://github.com/respond-framework/rudy/blob/3c184800682bbfa5adaecb7e8aef3657cb0ff9f6/packages/rudy/src/middleware/transformAction/utils/formatAction.js#L30
https://github.com/respond-framework/rudy/blob/3c184800682bbfa5adaecb7e8aef3657cb0ff9f6/packages/rudy/src/actions/history.js#L34
Basically you import
reset
and it will create a redux action that resets the entire history stack to whatever you wantIt seems like no matter what i try with regard to pushing/replacing/resetting state on initial page load, i dont get the back button functionality (it’s grayed out).
But if I browse to a page and then back, the new history has been inserted and takes the correct number of button presses (so one more will go to the new Page / button is active).
Do you think this is a chrome issue and not a router issue?
Thanks again
edit: doesn’t seem related to lib so closing.