![]() With the exact same type string, the corresponding reducer will be run. Also, if any other part of the application happens to dispatch an action The keys in the object will be used to generate string action type constants, and these will show up in the ReduxĭevTools Extension when they are dispatched. reducers Īn object containing Redux "case reducer" functions (functions intended to handle a specific action type, equivalent Generated action type constants will use this as a prefix. name Ī string name for this slice of state. This API is the standard approach for writing Redux logic. Once a slice is created, we can export the generated Redux action creators and the reducer function for the whole slice. What is slices in Redux tool kit A function that accepts an initial state, an object of reducer functions, and a 'slice name', and automatically generates action creators and action types that correspond to the reducers and state. This will be used whenever the reducer is called with undefined as its state value, and is primarily useful for cases like reading initial state from localStorage. Creating a slice requires a string name to identify the slice, an initial state value, and one or more reducer functions to define how the state can be updated. This may also be a "lazy initializer" function, which should return an initial state value when called. ![]() The initial state value for this slice of state.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |