![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcmiIaW%2Fbtq9kPv3bnh%2FCkKzKGfAvxqSvhaFgqh0p1%2Fimg.png)
๋์ด๋ : ๊ณจ๋ 2 ๋ฌธ์ ์ด์ง ํ์ ํธ๋ฆฌ ๋ณต์ํ๊ธฐ ๋ฌธ์ ๋ฐ๋ก๊ฐ๊ธฐ 1๋ถํฐ N๊น์ง์ ๋ชจ๋ ์ ์๋ฅผ ํ ๋ฒ์ฉ ํฌํจํ๊ณ ์๋ ์์ด A1, A2, ..., AN์ด ์๋ค. ๊ฐ์ด A1์ธ ๋ ธ๋๋ฅผ ๋ฃจํธ๋ก ํ๋ ํธ๋ฆฌ์ A2, A3, ..., AN ์ ์์๋๋ก ์ฝ์ ํ๋ ค ํ๋ค. N-1๊ฐ์ ๋ ธ๋๋ฅผ ์ฝ์ ํ ๋๋ง๋ค ๋ฃจํธ์์ ๊ทธ ๋ ธ๋์ ๋๋ฌํ๊ธฐ ์ํด ๊ฑฐ์ณ์ผ ํ๋ ๊ฐ์ ์ ์, ์ฆ ๋ ธ๋์ ๊น์ด๊ฐ ์ฃผ์ด์ง ๋ A1, A2, ..., AN์ ๊ตฌํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค. ํ์ด ๊ฐ ๋ฐ์ผ๋ฉด์ 2N(n-1)children.size() > 0) { // ์ผ์ชฝ ์์ ์กด์ฌ Inorder(head->children[0]); } result[head->index] = idx++; if (head->children.size() > 1) { // ์ค๋ฅธ์ชฝ ์์ ..
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์ ๋ค๋ฅด๊ฒ 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