So we're going to give it a value of null, I don't want it to be set to anything right because no pet has been adopted until they click the AdoptPet button. The initial state, we have to give us some sort of initial state of like what we want this particular item in our little database to be when you first create it. What is the name of the slice this name is the adoptedPet, okay. And then we're going to export const adoptedPetSlice = createSlice, so first of all you have to give it a name. So import, create slice from at Redux toolkit. That the term that they use to describe that bundle of putting everything together is a slice. ![]() What is a slice? A slice is kind of a new idea for Redux Toolkit, but basically it's the idea of, I'm putting all the reducers, and action creators and all that stuff together in one particular bundle, right? ![]() So you can just delete that from your app and make a file called adoptedPetSlice.js. Let's go ahead and delete adopted pet context coz we're not gonna use that anymore. Now we have access to reducts inside of our applications. Transcript from the "Creating a Slice" Lesson
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |