๐ป DEV/React-Query5 [ReactQuery] ReactQuery - ์ค์ ํ์ผํ์ ์ ๊ทผ (์์ฝ)์ ๊ฐ๊ธฐ ๋ค๋ฅธ React-query ์ค์ ํ์ผ์ ๋ค๋ค๋ณด๊ธฐ์ํด ์์ฑํ๋ค. 1. .mjs (eslint.config.mjs) 2. .json (eslint.json) 3. .cjs (.eslintrc.cjs)๋ฐฉ๋ฒ 1. .mjs (eslint.config.mjs)import { dirname } from "path";import { fileURLToPath } from "url";import { FlatCompat } from "@eslint/eslintrc";const __filename = fileURLToPath(import.meta.url);const __dirname = dirname(__filename);const compat = new FlatCompat({ baseDire.. 2025. 7. 17. [ReactQuery] (4) ReactQuery - useIsFetching (feat. Nextjs) ์ ๊ทผ (์์ฝ)์ฑ์์ isLoading ๊ณผ isFetching๋ง์ ์ฌ์ฉํด ์ปดํฌ๋ํธ๋ง๋ค ๊ฐ๋ณ Loading Indicator๋ง์ ํ์ฉํ๋ค๋ฉด,useIsFetching์ ๋ํด์ ์๊ฒ ๋๊ณ ๋ ํฐ ์ฑ์ ์ค์ ์ง์ค์ Loading Indicator๋ฅผ ์ฌ์ฉํด๋ณด๊ธฐ ์ํด ์ ๋ฆฌ๋ฅผ ๋จ๊ธด๋ค. 1. isLoading & isFetching & useIsFetching 2. useIsFetching ์ ์ฉํ๊ธฐ 3. ์ ์ฉ TEST๋ฐฉ๋ฒ 1. isLoading & isFetching & useIsFetching# useIsFetching- ๊ฐ ์ปดํฌ๋ํธ์ ๋ํด "๊ฐ๋ณ ๋ก๋ฉ ์ธ๋์ผ์ดํฐ (Loading Indicator)" ๋ฅผ ์ฌ์ฉํ๋ ๋์ - "์ค์ ์ง์ค์ ๋ก๋ฉ ์ธ๋์ผ์ดํฐ"๋ฅผ ์ฌ์ฉํ๋๋ก ์ฑ์ ์ ๋ฐ์ดํธ ํ ์์ !>> useIsF.. 2025. 3. 19. [ReactQuery] (1) ReactQuery ๋ ๋ฌด์์ธ๊ฐ? ์ ๊ทผ (์์ฝ)reactQuery์ ๊ฐ์๋ฅผ ์์ฑํ๋ค. 1. Client State vs Server State 1. Client State - ์น ๋ธ๋ผ์ฐ์ ์ธ์ ๊ณผ ๊ด๋ จ๋ ๋ชจ๋ ์ ๋ณด ์๋ฏธ (๋จ์ํ ์ฌ์ฉ์์ ์ํ) (ex_ ์ฌ์ฉ์๊ฐ ์ํ๋ ์ธ์ด๋ฅผ ์ ํํ๊ฑฐ๋ ๋ฐ์/์ด๋์ด ํ ๋ง๋ฅผ ์ ํํ๋ ๋ฑ์ ์๋ฒ์์ ์ผ์ด๋๋ ์ผ๊ณผ๋ ์๋ฌด ๊ด๋ จ์ด ์๋ ๊ฒ)2. Server State- ์๋ฒ ์ํ๋ ์๋ฒ์ ์ ์ฅ๋์ง๋ง ํด๋ผ์ด์ธํธ์ ํ์ํ๋ ๋ฐ ํ์ํ ๋ฐ์ดํฐ (ex_๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ฑ ๋ธ๋ก๊ทธ ๊ฒ์๋ฌผ ๋ฐ์ดํฐ)- ๋ฐ์ดํฐ๋ ์ฌ๋ฌ ํด๋ผ์ด์ธํธ์ ํ์๋์ด์ผ ํ๊ธฐ์ ์๋ฒ์ ์ ์ฅ๋จ 2. React Query ํน์ง 1. React Query๋ ํด๋ผ์ด์ธํธ์์ ์๋ฒ ๋ฐ์ดํฐ ์บ์๋ฅผ ๊ด๋ฆฌ React Code ↔ React Query Cache ↔ S.. 2025. 3. 15. [ReactQuery] (3) ReactQuery - customHooks (feat. Nextjs) ์ ๊ทผ (์์ฝ)reactQuery๋ฅผ ํ์ฉํด custom hooks์ ์์ฑํ๋ค. (queryKey์ queryFn) 1. queryKey Object (queryKey Namespace) ํจํด์ผ๋ก ์ ๋ฆฌ- queryKey : ๋ฐ์ดํฐ ์์ฒญ์ ์๋ณํ๋ ์ค์ํ ์ญํ - ์ฟผ๋ฆฌ ํค ๋ค์์คํ์ด์ค ํจํด์ ํ์ฉํ ํจ์จ์ ๋ฐ์ดํฐ ๊ด๋ฆฌ- ./react-query/index.ts 2. hooks ํด๋ ๋ด์ customHooks ์์ฑ => useExampleQuery.ts- app/hooks/queries/useExampleQuery.ts- app/hooks/queries/mutation/useExampleMutation.ts 3. useExampleQuery.ts (CustomHooks ์ฝ๋ ํ์)- Data Fet.. 2025. 3. 15. [ReactQuery] (2) Nextjs ํ๋ก์ ํธ์ ReactQuery ์ ์ฉ ์ ๊ทผ (์์ฝ)Next.js ๋ฅผ ํตํด ๊ฐ๋ฐ์ ์งํํ๋๋ฐ, Web App์ ์๋ฒ ์ํ๋ฅผ ๊ด๋ฆฌํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ํ์์ ์ด๋ค.๊ณต์ ์น์ฌ์ดํธ๋ฅผ ํ์ธ ํด๋ณด๋ฉด, npm ์์์ ๋์ ๋ค์ด๋ก๋ ์๊ฐ 18์ต์ ์ก๋ฐํ๊ณ ์ค์๊ฐ์ผ๋ก ์์น๊ฐ ์์นํ๋ ๊ฒ์ ๋ณด๊ธฐ๋ง ํด๋์ผ๋ง๋ ํซํ ๊ธฐ์ ์ธ์ง ํ์ธ์ด ๊ฐ๋ฅํ๋ค. ์ด๋ฅผ ํ๋ก์ ํธ์ ๋์ ํ์ฌ ์น์ดํ๊ฒ ์ฐ๊ตฌ๋ฅผ ํด๋ณด๊ณ ์ ํ๋ค.(์์ ์ ๊ฐ๋ฐ ๋์ ๋๋ฌธ๋๋ฌธ ํ์ฉํ๋ ๊ฒ ๊ทธ ์ด์์ผ๋ก ์น์ํด์ง๊ณ ์ ํ๋ค) 1. ReactQuery ์ค์น- npm install @tanstack/react-query- npm install @tanstack/react-query-devtools 2. ESLint Plugin ์ค์น- npm i -D @tanstack/eslint-plugin-query- ๊ธฐํ ์ค์ (... 2025. 3. 14. ์ด์ 1 ๋ค์