React Redux Cant add item into list in the state

前端 未结 1 1433
难免孤独
难免孤独 2020-12-04 03:58

The initialState for the list is works perfectly, and i can found the console log in the reducre too .

However its failed to add one more item in the list.

I

相关标签:
1条回答
  • 2020-12-04 04:41

    You're currently replacing whole state. You should do like this:

    return {
     ...state,
     products1: [...state.products1,
      { // I hope, you'll merge action.payload later
       id: "123",
       abbreviation: "123",
       case_no: "123",
       created_dt: "31/01/2018",
       last_updated: "11:43:45"
      }
     ]
    }
    
    0 讨论(0)
提交回复
热议问题