dfgdfg
Gnaneh
0
0
react Redux Toolkit Not Updating State as Expected
asked 1 year ago Votes
2 Answers
15 Views
I'm dispatching the increment action, but the state is not updating as expected. What could be the issue, and how can I ensure that the state updates correctly when using Redux Toolkit?
import { createSlice } from '@reduxjs/toolkit';
const counterSlice = createSlice({
name: 'counter',
initialState: { value: 0 },
reducers: {
increment: (state) => {
state.value += 1;
},
},
});
export const { increment } = counterSlice.actions;
export default counterSlice.reducer;
2 Answers
dfgdfg