๐ย Reference
import { ReactQueryDevtools } from "react-query/devtools";
import './App.css';
import { Routes, Route, Link } from 'react-router-dom';
import { QueryClient, QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from 'react-query/devtools';
import { HomePage } from './components/Home.page';
import { RQSuperHeroesPage } from './components/RQSuperHeroes.page';
import { SuperHeroesPage } from './components/SuperHeroes.page';
const queryClient = new QueryClient();
function App() {
return (
<QueryClientProvider client={queryClient}>
<nav>
<ul>
<li>
<Link to='/'>Home</Link>
</li>
<li>
<Link to='/super-heroes'>Traditional Super Heroes</Link>
</li>
<li>
<Link to='/rq-super-heroes'>RQ Super Heroes</Link>
</li>
</ul>
</nav>
<Routes>
<Route path='/' element={<HomePage />} />
<Route path='/super-heroes' element={<SuperHeroesPage />} />
<Route path='/rq-super-heroes' element={<RQSuperHeroesPage />} />
</Routes>
<ReactQueryDevtools initialIsOpen={false} position='bottom-right' />
</QueryClientProvider>
);
}
export default App;
freshfetchingstaleinactive์ ๊ฐ์ Data Fetching State๋ฅผ ํ์ธํ ์ ์๋ค.
Observer๋ ํด๋น API call๋ฅผ ์์ฒญํ๋ observer์ ์๋ฅผ ๋ํ๋ด๋ฉฐ, ์ด ๊ฒฝ์ฐ์ RQ super heroes page ๋ด์ useQuery call์ ๋ํ๋ธ๋ค.Last Updated์์ ๋ง์ง๋ง์ผ๋ก query๋ฅผ ๋ถ๋ฌ์จ ์๊ฐ์ ํ์ธํ ์๋ ์๋ค.Actions ๋ฒํผ์ query์ ๊ด๋ จ๋ action์ ํด๋ณผ ์๋ ์๋ค.