Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve input value states with history #1188

Closed
dmitry opened this issue May 13, 2015 · 4 comments
Closed

Preserve input value states with history #1188

dmitry opened this issue May 13, 2015 · 4 comments

Comments

@dmitry
Copy link

dmitry commented May 13, 2015

Normally (it depends on the caching strategy sending in headers from the server and few other circumstances), when you are changing location in your browser by pressing the link, sending a form or any other way, you can retrieve back all the values of your inputs once you click on the "back" button in your browser.

How do I preserve inputs with react-router when changing browser history from current page to previous?

@dmitry dmitry changed the title Save input value states Preserve input value states with history May 13, 2015
@agundermann
Copy link
Contributor

There's currently no way to make use of the browser's history state object (there are plans though).

I'd say the best you can do right now (without some serious effort) is to store the state (indexed by path) yourself in some variable, and persist it using sessionStorage if you want to. You can check state.action === 'pop' to avoid restoring state after clicking a link.

@dmitry
Copy link
Author

dmitry commented May 26, 2015

Just to mension some related things I've found:

#843
#1200

@ryanflorence
Copy link
Member

the new location.state feature in 1.0 would allow this

https://rackt.github.io/react-router/tags/v1.0.0-beta2.html#Router

Look at the transitionTo(pathname, query, state) method there.

(also, we'll be writing up a guide on the state feature)

@dmitry
Copy link
Author

dmitry commented Jun 20, 2015

@ryanflorence how do I change the state for the back/forward browser events?

@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants