react Redux Toolkit Not Updating State as Expected

clock icon

asked 1 year ago Votes

message

2 Answers

eye

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

Write your answer here

Top Questions