Let's say I am using react-router, with two routes /page1, /page2 I am currently on Page1.jsx, and I want to move to Page2.jsx, passing some state.
On Page1.jsx I can use :
<Redirect
to={{
pathname: '/page2',
state: { prop1:val1, prop2:val2 }
}}
/>
On Page2.jsx, I can retrieve the state with:
props.location.state
While on /page2, if the user decides to hit the Browser refresh, then /page2 is NOT loaded as a result of a react-router Redirect; so the state will be null/undefined.
What's the standard or best-practice way to handle such a scenario (of the user hitting Browser refresh), such that the state passed from /page1 is still retained?