History: Lose window.history.state after page refresh

Created on 5 Jan 2018  路  3Comments  路  Source: ReactTraining/history

Hi.

I do not know if a problem in the history library or browser, but ...

I am working on Firefox Quantum 57.0.4 64 bit, and when I select the url and press enter, after updating the page I can not get the history.location.state. After investigating, I discovered that window.history.state is null.

Does anyone have this error?

Most helpful comment

I have the same issue. It's very clear and I'm not sure this package can do anything about it. if you do this:

  history.push('/home', { some: 'state' })

when you go to home you have some === 'state' and if you refresh in chrome you get that state again which is stupid. In Firefox, things are different and a refresh is counted a fresh new start and you don't have that state which I think is much better. In chrome you have to close the tab and open a new one to get ride of that state.

All 3 comments

We need more info in order to help you debug this. Can you show a small, reproducible test case?

I have the same issue. It's very clear and I'm not sure this package can do anything about it. if you do this:

  history.push('/home', { some: 'state' })

when you go to home you have some === 'state' and if you refresh in chrome you get that state again which is stupid. In Firefox, things are different and a refresh is counted a fresh new start and you don't have that state which I think is much better. In chrome you have to close the tab and open a new one to get ride of that state.

@mjackson sorry my delay.
Yes, basically, when you set in the state, and refresh the page, it is lose the state value.
The example of @ImanMh is the correct scenery for reproduce. This is only with Firefox Quantum

Was this page helpful?
0 / 5 - 0 ratings