์ํฉ next.js์์๋ SSR์ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ url์ ์๋ query๋ฅผ ๋ฐ์์ฌ ์๊ฐ ์๋ค. ํด๊ฒฐ 1 next page์์ getServerSideProps ํจ์๋ฅผ ์ด์ฉํด query๋ฅผ ๋ฐ์์ฌ ์ ์๋ค. const Page: NextPage = ({ params }) => { } export async function getServerSideProps (context) { const req = context.req; const params = new URLSearchParams(req._parsedUrl.query); return { props: { params } }; }โ ํด๊ฒฐ 2 ํด๊ฒฐ 1์ ๋ฐฉ๋ฒ์ผ๋ก page ๋ด๋ถ์์๋ url parameter๋ฅผ ์ฌ์ฉํ ์ ์๋ค. ํ์ง๋ง _app.tsx์ ๊ฐ์ด ne..
React-query : fetch, cache, synchronize, update(for server state)์ ์ฌ์ฉ๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ด๋ค. ๊ณต์์ฌ์ดํธ React Query Hooks for fetching, caching and updating asynchronous data in React react-query.tanstack.com ๋ฐฐ๊ฒฝ server state ์ฌ์ฉ ์ ๋ฐ์ํ ์ ์๋ ๋ฌธ์ ์ ์ ๋ค์๊ณผ ๊ฐ๋ค. caching deduping(๋ฐ์ดํฐ ์ค๋ณต ์ ๊ฑฐ) update "out of date" data / know when is it reflecting updates data pagination optimization, lazy loading data memory management, garba..
query๊ฐ ์ค๋ ๋์๋ค๋ ๊ฒ์ ํ๋จํ๊ณ ๋ค์ fetchํด์ฌ ๋, queryClient.invalidateQueries ํจ์๋ฅผ ์ฌ์ฉํ๋ค. https://react-query.tanstack.com/guides/query-invalidation Query Invalidation Query Invalidation Waiting for queries to become stale before they are fetched again doesn't always work, especially when you know for a fact that a query's data is out of date because of something the user has done. For that purpose, the Quer..
query์ ๋ค๋ฅด๊ฒ CUD์ ์ฌ์ฉ๋๋ค. https://react-query.tanstack.com/guides/mutations Mutations Subscribe to our newsletter The latest TanStack news, articles, and resources, sent to your inbox. react-query.tanstack.com ์ฌ์ฉ์์ const mutation = useMutation(newTodo => axios.post('/todos', newTodo)) return ( {mutation.isLoading ? ( 'Adding todo...' ) : ( {mutation.isError ? ( An error occurred: {mutation.error.mes..
๊ธฐ๋ณธ ์ฌ์ฉ const info = useQuery('unique_key', fetchData); // fetchData๋ promise ๋ฐํ uniqueํ key๋ก ์ ์ํ๋ฉฐ, key์ ๋ฌถ์ด๋ ๋ฐ์ดํฐ๋ ๋น๋๊ธฐ ๋ฐ์ดํฐ์ด๋ค. useQuery๊ฐ ๋ฐํํ๋ result๋ ๋น๋๊ธฐ ๋ฐ์ดํฐ์ ์ํ๋ฅผ ๋ด๊ณ ์๋ค. ์ํ loading isLoading์ด true๊ฐ ๋๋ค. error isError๊ฐ true๊ฐ ๋๋ฉฐ, error์ ์๋ฌ ์ ๋ณด๊ฐ ๋ด๊ธด๋ค. success isSuccess๊ฐ true๊ฐ ๋๋ฉฐ, data์ ์ ๋ณด๊ฐ ๋ด๊ธด๋ค. idle ์ฌ์ฉ ์์ const { isLoading, isError, data, error } = useQuery('key', fetchData); // const { status, data, erro..
Comment