From the course: Learning Redux Toolkit
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Working with slices in Redux Toolkit
From the course: Learning Redux Toolkit
Working with slices in Redux Toolkit
- [Instructor] A Redox app can have as many slices as it's needed to represent each part of the application. So you can think of is slice the way you think of parts of a pizza or a loaf of bread. To create a slice, you need to import the create slice method from redox tool kit. Next, you create a variable for your slice and then assets value called the create slice method. The create slice method expects a single object as its arguments, which is used to configure the slice. For the object properties, we need to provide values for name, initial states, and reducers. There's also an optional property named extra reducers. The name property tells redox the name of the slice of our app state. The initial property provides a store with the initial state value of the slice of state. This value can be of any type, including strings, arrays, objects and boolean. The reducers property is where we write the different reducers for…