DEV Community

Discussion on: Passing Data with React Router using Link

Collapse
 
ercumentlacin profile image
ercüment

when the third method is applied, if you refresh the page the state will be undefined.

Collapse
 
ryanflorence profile image
Ryan Florence

That's not correct. It will be there since its stored in the browser's session memory, not your application's. It will be there until you close the browser (or a new tab). It's like a hidden piece of the URL.

Collapse
 
medaminefh profile image
Mohamed Amine Fh

Actually that's how react works, if you refresh the page in any component, the state will reset.
if you're trying to send some data (you get it from the server using fetch API) to another component, and you want to refresh the page or to handle the page from crushing, just fetch again that specific data.