728x90

 The object notation for `createSlice.extraReducers` is deprecated, and will be removed in RTK 2.0.

라는 WARN 이 콘솔에서 계속 보여 처리하기로 맘 먹었다.

 

 이제는 사용되지 않을것이다.. 라고 하니 다르게 수정해줘야 겠다.

 

아래 코드는 원래 createSlice 안에 있는 extraReducers의 코드이다.

이를 builder와 addCase가 들어간 함수로 수정해주면 된다.

 // 수정 전 코드
 extraReducers: {
     [A.success]: (state, action) => {
       state.A = action.payload;
     },
     [A.failed]: (state, action) => {
       state.A = null;
     },
   },

 

// 수정 후 코드
extraReducers: (builder) => {
    builder
      .addCase(A.success, (state, action) => {
        state.A = action.payload;
      })
      .addCase(A.failed, (state) => {
        state.A = null;
      });
  },

 

builder와 addCase를 통해서 기존 함수를 재구성해주면

해당 워닝을 제거할 수 있다! 간단간단

 

자..이제 재 역할을 잘 하는 지 확인하러.. 총총..

728x90

+ Recent posts