[유데미] React Query : React로 서버 상태 관리하기
📍클라이언트 상태 vs 서버 상태
- client state : 브라우저의 세션과 관련된 데이터
예) 언어, 테마 등 유저가 선택하는 정보
- server state : 서버에 저장된 데이터
fetching과 updating을 위해 비동기 API가 필요
예) DB에 저장된 post들
📍React Query의 역할
- React 앱에서 서버 상태를 쉽게 fetching, caching, synchronizing, updating 할 수 있다
- fetch로 바로바로 HTTP 요청을 보내서 데이터를 가져오는 것 대신 React Query가 cache한 데이터를 사용
- pagination / infinite scroll 쉽게 구현 가능
📍TanStack Query
- React Query v4(2022/7/20)부터 TanStack Query로 이름이 바뀜
📍참조
https://tanstack.com/query/v4/docs/react/overview
Overview | TanStack Query Docs
React Query is often described as the missing data-fetching library for React, but in more technical terms, it makes fetching, caching, synchronizing and updating server state in your React applications a breeze. Motivation
tanstack.com