본문 바로가기

A.개발관련자료

[0]the object notation for `createslice.extrareducers` is deprecated, and will be removed in rtk 2.0. please use the 'builder callback

the object notation for `createslice.extrareducers` is deprecated, and will be removed in rtk 2.0. please use the 'builder callback,

addcase cannot be called with two reducers for the same action type

와 같은 리덕스툴킷 에러가 뜨면 시도해봐야 할것 :

extraReducer의 구조가 변경돼어 생기는 에러 인 것 같아, docs를 뒤져본 결과 

하단과 같이 구조를 변경하면 제대로 작동하였다.

 

//before

extraReducer:{
    // [getAllPosting.fulfilled]:(state,action) =>{
    //   state.status = "success"
    //   state.postingList = action.payload.postingList
    // },
    // [getAllPosting.pending]:(state) =>{
    //   state.status = "pending"
    // },
    [...]
}

//after

  extraReducers:(builder)=>{
    builder.addCase(getAllPosting.fulfilled,(state,action)=>{
      state.status = "success"
      state.postingList = action.payload.postingList
    })
    builder.addCase(postingSearch.fulfilled,(state,action)=>{
      state.status = "success"
      state.postingList = action.payload.postingList
    })
    [...]
    }