Conteúdo do Curso
State Management with Redux Toolkit in React
State Management with Redux Toolkit in React
2. Applying Redux Toolkit in React
What AwaitsUnderstanding the Project Code and File StructureCreating the Redux StoreIntegrating the Redux Store Into the React AppInspecting the Store in the React AppUnderstanding Actions and Action CreatorsUnderstanding the Role of ReducersInspecting Actions and Reducers in ReduxConnecting Redux with React ComponentsCompleting the App
Challenge: Creating Redux Actions
Step 2
Focus on creating actions for managing goals. Actions are objects that describe the changes we want to make to the state. By creating actions, we can update the Redux store accordingly.
Example
Challenge
- Open the
goalAction.js
file. - Use the correct function from the
@reduxjs/toolkit
package to create actions. - Specify the correct action types using the target element
goal
and indicate the action for each action. - To remove a goal, set the action type as
goals/removeGoal
. - To add a goal, set the action type as
goals/addGoal
.
- The
createAction
function simplifies the process of creating action creators. - The action types should be descriptive and reflect the purpose of the action.
- Using string constants or variables is recommended for consistency and easier refactoring.
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 3. Capítulo 4