• Redux: is a state management JavaScript library.
  • react-redux: used to implement redux in react-app, or connect react-app with the store(all states are stored there).
  • redux-store: the main central bucket which stores all the application states.

Redux focus on:

  • Single source of truth (means single/one store only).
  • States should be read-only.
  • Never modify/mutate your state.
  • State changes should be made through pure functions/(reducers).

🚀 Redux moved to RTK(redux-toolkit)
why...???

Redux issues:

  • middleware debugging issue.
  • redux-thunk concept.
  • create a store is lengthy process(lots of configurations).

RTK(redux-toolkit):

  • give a simple flow to the app, all other things will be managed internally by Redux itself.
  • easy way to create a store.
  • built-in middleware.
  • slicing concept(how to store reducer/fun).

working:

  • store: a container that holds global states/data of your application, (store could have mini stores/portions inside).
  • reducer: reducers are functions that handle state logic, all the functionality of the app is controlled(change/update) in a state by reducers.
  • useSelector: this method is used to select a value from the store.
  • useDispatch: this method is used to send a value from the store.