Search code examples
reactjsreduxreact-hooksstateredux-toolkit

How to CLEAR STATE in redux Toolkit


This is my Code, But when we click other component this state remain same after refresh its OK

[getOrderList.fulfilled]:(state, action) => {
  state.getUsersOrderList = [...state.getUsersOrderList, action.payload];
},

I Want to clear my previous state on payload


Solution

  • You could do this by only using the action.payload in your array

    [getOrderList.fulfilled]:(state, action) => {
      state.getUsersOrderList = [action.payload];
    },