react redux toolkit
react redux toolkit
Cheatsheets / Redux
Redux Toolkit
Redux Toolkit
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 1/10
08/02/2025 00:37 Redux: Redux Toolkit Cheatsheet | Codecademy
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 2/10
08/02/2025 00:37 Redux: Redux Toolkit Cheatsheet | Codecademy
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 3/10
08/02/2025 00:37 Redux: Redux Toolkit Cheatsheet | Codecademy
const store =
createStore(countUpReducer);
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 4/10
08/02/2025 00:37 Redux: Redux Toolkit Cheatsheet | Codecademy
const store =
createStore(countUpReducer);
console.log(store.getState());
// Output: 0
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 5/10
08/02/2025 00:37 Redux: Redux Toolkit Cheatsheet | Codecademy
const store =
createStore(countUpReducer);
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 6/10
08/02/2025 00:37 Redux: Redux Toolkit Cheatsheet | Codecademy
Introduction To Redux
Store
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 7/10
08/02/2025 00:37 Redux: Redux Toolkit Cheatsheet | Codecademy
Actions
/*
Action object for a shopping list
that adds an item to the list
*/
const addItem = {
type: 'shopping/addItem',
payload: 'Chocolate Cake'
}
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 8/10
08/02/2025 00:37 Redux: Redux Toolkit Cheatsheet | Codecademy
Reducers
const shoppingReducer = (
state = [],
action
) => {
switch (action.type) {
case "shopping/clear":
return [];
case "shopping/addItem":
return [
...state,
action.payload];
default:
/*
If the reducer doesn't care
about this action type, return
the existing state unchanged
*/
return state;
}
}
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 9/10
08/02/2025 00:37 Redux: Redux Toolkit Cheatsheet | Codecademy
Print Share
https://www.codecademy.com/learn/fscp-redux/modules/refactoring-with-redux-toolkit/cheatsheet 10/10