0

Rapid question: Is React Redux projected to work like a single page application?

I'm using Redux to control my application state. I have noticed that when I refresh the page(application), the state returns to the initial state and I have concluded that I can't use the browser's functions to navigate and refresh pages.

JensG
  • 13,148
  • 4
  • 45
  • 55
  • This might be interesting, connected to your question: https://stackoverflow.com/questions/38329193/where-is-redux-store-saved – 5ar Jan 22 '18 at 16:07
  • thks. Thats interesting, cause somethings I dont want to save on local storage cause this is acessible to anyone – Marcos Henrique Jan 22 '18 at 17:30

2 Answers2

0

Yes, Redux is just a framework that offers an easy way for complex state management. Refreshing the page will still cause the state to reset, you have to save the state to some kind of storage (either to some backend server or in the browser via storage or cookies).

If you need to maintain the state on refresh, I suggest you add some middleware to autosave the state to localStorage, Dan Abramov has touched on this here

5ar
  • 2,069
  • 10
  • 27
0

No and yes.

Redux can be used with applications having many pages. When you use React Router, you can have many routes in your app, all controlled by the same Redux store. There is also react-router-redux which is used to create bindings between Redux store and application routes.

That said, Redux store cannot persist across page reloads. You may use redux-persist for that functionality.

Dane
  • 9,242
  • 5
  • 33
  • 56