ContextAPI와 Recoil
-
ContextAPI와 Recoil개발공부/기타 2024. 1. 15. 16:47
지금 지인들과 진행하고 있는 사이드 프로젝트가 하나있다. 처음에는 관리해야 할 데이터가 별로 없어서 ContextAPI를 사용했는데, 시간이 지날수록 불편한 점들이 있어서 팀원들과 논의한 결과 Recoil을 사용하기로 결정했다! :) 변경한 이유는? ContextAPI를 불편하게 생각했던 이유는 아래와 같다. 코드 간결성 및 가독성 불필요한 리렌더링 발생 코드 간결성 및 가독성 ContextAPI에 로그인 유무를 저장한 변수가 있었는데 분명 boolean으로 저장했는데 console에 찍으면 int이 찍혀있는 것이었다. 디버깅을 통해 원인을 파악해보니 팀원 중 한명이 코드를 잘못 작성해서 int형으로 데이터가 잘못들어갔던 것이다. (주석 참고) export const AuthProvider = ({ ch..