Grokking React Native
0% completed
Creating and Managing State with Slices
The name you give a slice does not decide where its state lives in the store. Here is the counter slice from the previous lesson, added to a store under a different key:
const store = configureStore({ reducer: { score: counterReducer, }, }); store.dispatch(increment()); console.log(JSON.stringify(store.getState())); console.log(increment.type);
{"score":{"value":1}} counter/increment
The state appears under score, which is the key you passed to configureStore, while the slice's name counter only appears in the action type
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%