[TanStack Query] 설치 및 셋팅

참고

설치

TanStack Query

  • 리액트 v16.8+ 부터 호환
$ npm i @tanstack/react-query
# or
$ yarn add @tanstack/react-query

Devtools

  • 선택
$ npm i @tanstack/react-query-devtools
# or
$ yarn add @tanstack/react-query-devtools

셋팅

_app.tsx 설정

// _app.tsx
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';

const queryClient = new QueryClient();

const App = () => {
  const queryClient = new QueryClient();

  return (
    <QueryClientProvider client={queryClient}>
      ...
      <ReactQueryDevtools initialIsOpen={false} /> // Devtools
    </QueryClientProvider>
  )
}

export default App;

links

social