0

Is there a common place solution to preserving state between routes in React.js?

I'm not entirely sure I'm asking the right question, but to clarify here is an example:

You search something on Google, scroll down the page and click on a link. When you hit the back button you are brought back to the same search and even the same scrolling point you left off at.

Neil
  • 2,004
  • 3
  • 23
  • 48

1 Answers1

0

I'm not quite sure what you mean by commonplace, but a solution many developers use with React is Redux.

Redux is a state management tool that allows you to store an application state even when you refresh the page or navigate forward, then backwards.

https://redux.js.org/basics/usagewithreact

There are multiple middlewares that have been created to make sure the state persists after refreshes - here are some examples:

How can I persist redux state tree on refresh?

havak5
  • 714
  • 1
  • 6
  • 20