react query - team-yaza/mozi-client GitHub Wiki

react-query๊ฐ€ ์ƒํƒœ๊ด€๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋Œ€์ฒดํ•  ์ˆ˜ ์žˆ๋Š”๊ฐ€

react-query๋Š” ํด๋ผ์ด์–ธํŠธ ์ƒํƒœ์˜ ์บ์‹œ ๋ฐ์ดํ„ฐ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ์ฝ”๋“œ๋ฅผ ๋‹จ ๋ช‡์ค„์˜ ์ฝ”๋“œ๋กœ ๋Œ€์ฒดํ•  ์ˆ˜ ์žˆ๋‹ค.
๋Œ€๋‹ค์ˆ˜์˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ๋ชจ๋“  ๋น„๋™๊ธฐ ์ฝ”๋“œ๋ฅผ react-query๋กœ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ํ•œ ํ›„ ๋‚จ๊ฒจ์ง€๋Š” ์ „์—ญ ์ƒํƒœ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ๋งค์šฐ ์ ๋‹ค.

There are still some circumstances where an application might indeed have a massive amount of synchronous client-only state (like a visual designer or music production application), in which case, you will probably still want a client state manager. In this situation it's important to note that React Query is not a replacement for local/client state management. However, you can use React Query along side most client state managers with zero issues.

์˜ˆ์ œ๋ฅผ ํ•˜๋‚˜๋ณด์ž. ์ „์—ญ ์ƒํƒœ๊ด€๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ์˜ํ•ด ๊ด€๋ฆฌ๋˜๋Š” ์ƒํƒœ๋“ค์ด ์žˆ๋‹ค.

 const globalState = {
   projects,
   teams,
   tasks,
   users,
   themeMode,
   sidebarStatus,
 }

์—ฌ๊ธฐ์„œ server-state๋“ค์„ react-query๋กœ ์˜ฎ๊ธฐ๋ฉด ์ „์—ญ ์ƒํƒœ๋Š” ๋งŽ์ด ์ œ๊ฑฐ๋œ๋‹ค.
(์•„๋ž˜ ๋‚จ์€ ์ƒํƒœ๋Š” MOZI์™€ ์œ ์‚ฌํ•˜๋‹ค.)

const globalState = {
   themeMode,
   sidebarStatus,
 }

์ด ๋œป์€ ๊ธฐ์กด์˜ ์„œ๋ฒ„ ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•˜๊ธฐ์œ„ํ•ด ์‚ฌ์šฉํ–ˆ๋˜ boilerplate code๋ฅผ ๋งŽ์ด ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Œ์„ ์˜๋ฏธํ•œ๋‹ค.
๋‹จ์ง€ useQuery๋‚˜ useMutation์œผ๋กœ ์ด๋™์‹œํ‚ค๋ฉด ๋œ๋‹ค.

์„œ๋ฒ„์ƒํƒœ๋ฅผ ๋งŽ์ด ์ œ๊ฑฐํ•˜๋ฉด ํด๋ผ์ด์–ธํŠธ ์ƒํƒœ์กฐ์ฐจ ๋งค์šฐ ์ ๊ธฐ ๋•Œ๋ฌธ์— ์ „์—ญ ์ƒํƒœ๊ด€๋ฆฌ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ํ•„์š”์—†์–ด์งˆ ์ˆ˜๋„ ์žˆ๋‹ค.
react-query์˜ ์—ญํ• ์€ ๋ถ„๋ช…ํ•˜๋‹ค.
์„œ๋ฒ„์˜ ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•˜๊ธฐ์œ„ํ•ด ํ•„์š”ํ–ˆ๋˜ boilerplate code๋ฅผ ์ œ๊ฑฐํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋‹จ ๋ช‡์ค„์˜ ์ฝ”๋“œ๋กœ ๋Œ€์ฒดํ•œ๋‹ค.