forward Redux.

This React application uses a global state management system that is based on React-Redux . The Store configurations are located in the src/redux folder. Each module's actions are exported from src/redux/moduleReducerName/actions.js file. Each module's reducer is exported from src/redux/moduleReducerName/index.js file. The src/redux/store.js file is handling global redux-store of the project.

forward Adding New Action.

In Redux, actions are used to trigger changes in the store. To create an action, you first need to create a function that returns an object with a type property. This type property specifies the type of action that will be dispatched. The object can also contain other properties that contain data that will be used by the reducer.

  1. To do this, simply open up the actions file src/redux/moduleReducerName/actions/index.js , or create a new one, and add a new action:
  2. export const yourActionName = (data) => { // do something };
  3. Once you have created your action, you need to bind it to a dispatch function. This dispatch function is provided by the Redux store and is used to dispatch actions to the reducer.
  4. export const yourActionName = (data) => { return (dispatch) => { dispatch({ type: A_STRING_TYPE, payload: data, }); }; };
  5. Now, you need to add a new case for this action in the reducer.
  6. case A_STRING_TYPE: { return { ...state, state_variable: action.payload }; }
  7. You can then use this new function in your component to trigger the action.
  8. import yourActionName from "../redux/moduleReducerName/actions" dispatch(yourActionName(someData))