Search code examples
react-nativereduxreact-reduxredux-thunkredux-actions

What is a difference between action,reducer and store in redux?


I am new to react/redux. I am trying to figure out how all the pieces in redux interact. The one thing giving me trouble is understanding the relation between actions and reducers,store.


Solution

  • It's pretty simple when you think about it:

    • Store - is what holds all the data your application uses.
    • Reducer - is what manipulates that data when it receives an action.
    • Action - is what tells reducer to manipulate the store data, it carries the name and (optionally) some data.

    Reducer is usually in the format of a switch statement that switches between all possible Actions (cases) and then manipulates the Store data based on the action. When reducer data changes within redux, the properties in your components are changed and then the re-rendering occurs.