recoil
-
상태 관리개발공부/React 2024. 1. 16. 20:36
여러 가지 프로젝트를 진행하면서 내가 제일 많이 했던 고민이 바로 "상태 관리"이다. 상태 관리를 신경써야 하는 이유는 다양하지만 내가 중요하게 받아드리는 이유는 아래와 같다. 중앙 상태 관리를 통해 컴포넌트 간의 데이터 흐름을 쉽게 관리 가능 코드 유지 보수성 향상 상태의 불변성을 유지함으로서 예측 가능하고 안정적인 어플리케이션 구현 가능 어떻게 상태를 관리하는지에 따라 프로젝트의 성능이 달라진다. 위와 같은 이유로 프론트엔드 개발자는 특히 상태 관리를 잘해야 한다고 생각한다. (직접적인 영향이 있기 때문에) 그래서 오늘은 상태 관리가 뭔지, 어떤 방법으로 하는지에 대해 자세히 알아보려고 한다. 상태란? 우선 상태에 대해 찾아봤다. 어플리케이션 내에서 변경 가능한 데이터 리액트에서는 컴포넌트 내에서 관..
-
ContextAPI와 Recoil개발공부/기타 2024. 1. 15. 16:47
지금 지인들과 진행하고 있는 사이드 프로젝트가 하나있다. 처음에는 관리해야 할 데이터가 별로 없어서 ContextAPI를 사용했는데, 시간이 지날수록 불편한 점들이 있어서 팀원들과 논의한 결과 Recoil을 사용하기로 결정했다! :) 변경한 이유는? ContextAPI를 불편하게 생각했던 이유는 아래와 같다. 코드 간결성 및 가독성 불필요한 리렌더링 발생 코드 간결성 및 가독성 ContextAPI에 로그인 유무를 저장한 변수가 있었는데 분명 boolean으로 저장했는데 console에 찍으면 int이 찍혀있는 것이었다. 디버깅을 통해 원인을 파악해보니 팀원 중 한명이 코드를 잘못 작성해서 int형으로 데이터가 잘못들어갔던 것이다. (주석 참고) export const AuthProvider = ({ ch..