1

i want to know the main difference between Redux store and Local-storage, for example if i want to store data user like username and photourl and get them in any component hence i need them. thank you.

Srdjan Pazin
  • 103
  • 2
  • 5
Salah
  • 513
  • 7
  • 18

3 Answers3

1

Components connected to redux will update on redux value changes so if username/photourl change your components will pick up on it.

Redux store will also get cleared out unless you're using redux-persist which can store to local/session storage and re-hydrate redux store.

Matt Aft
  • 8,742
  • 3
  • 24
  • 37
0

Local Storage is a Web API. It means it's a functionality provided by the browser, with an interface for persisting data across sections. It acts like a hash table data structure whose keys and values are DOMStrings. It also has a max size per tab.

Redux is a library that is developed by a 3rd party, which is not limited to the browser environment and which can store more than simple (DOMString key, DOMString value) pairs. Redux, when used in a website, might use localStorage to initialize the store. For example, you might save the current user, a token, etc to localStorage.

tl;dr: use localStorage to save simple values and let Redux read from localStorage initially and handle the complex stuff.

Rodrigo Amaral
  • 1,324
  • 1
  • 13
  • 17
0

In simple Words, Local storage provided by browser and data stored can be access in browser only. where as Redux is State management Library, data can be stored in state and handled by redux.