본문 바로가기

카테고리 없음

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

위와 같은 에러가 뜨면 리덕스툴킷 에러라고 볼 수 있다.

extraReducer의 구조가 변경되면서 생기는 에러 인 것 같다, reduxt-toolkit docs를 확인해본 결과 

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

 

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


//fixed code
  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
    })
    [...]
    }