TIL 45일차

김동현·2022년 12월 21일

TIL

목록 보기
37/93

current()

extrareducer 에서 state 값을 보고 싶어서 console.log()를 입력하고 결과를 보면 procy 로 나와 내부 값을 볼수가 없습니다 하지만 current()를 이용해서 state 내부값을 볼수 있습니다!!

current 사용하지 않았을때

current 사용했을때

내부를 확인을 할수 있게 해준다!!

댓글수정 로직

state.data.= state.data.map((comment) => {
        if (comment.commentId === action.payload.commentId) {
        // 만약 맵으로 돌린 commentId가 action.payload에 commentId가 같으면 리턴값으로 action.payload 값을 넣어줍니다!
          return { ...action.payload };
        } else {
        // 아니면 comment 값을 넣어줍니다!
          return comment;
        }
      });
profile
꺽이지 않는 마음

0개의 댓글