2023-03-12

그 동안 Apollo만 오지게 썼었다가

React-Query 라는 좋은 도구가 나왔다는 이야기를 들었다.

써보니 편하고 괜찮더라고.

비슷한 형제로는 SWR, RTK Query 등이 있다.

장점

단점

Setup

npm i react-query       # npm
yarn add react-query    # yarn
// src/pages/App.tsx

import { QueryClient, QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from 'react-query/devtools';

const client = new QueryClient();

export default function App() {
  return (
    <QueryClientProvider client={client}>
      <ReactQueryDevtools />
      {...}
    </QueryClientProvider>
  );
}

useQuery