
Here's the complete counter application as a running CodeSandbox: What's Next? Get the dispatch function with the useDispatch hook, and dispatch actions as needed.Read data from the store with the useSelector hook.Use the React-Redux useSelector/useDispatch hooks in React components.Export the generated slice reducer and action creators.

Reducer functions may "mutate" the state using Immer.

REDUXJS TOOLKIT CREATESLICE HOW TO
For explanations of what Redux is, how it works, and full examples of how to use Redux Toolkit, see the tutorials linked in the "Tutorials Index" page.įor this tutorial, we assume that you're using Redux Toolkit with React, but you can also use it with other UI layers as well. This page will focus on just how to set up a Redux application with Redux Toolkit and the main APIs you'll use. Welcome to the Redux Toolkit Quick Start tutorial! This tutorial will briefly introduce you to Redux Toolkit and teach you how to start using it correctly.

