Skip to content

๐Ÿฆ ๋ฉ‹์Ÿ์ด์‚ฌ์ž์ฒ˜๋Ÿผ 12๊ธฐ SKHU ํ•ด์ปคํ†ค 5ํŒ€ ํ”„๋ก ํŠธ์—”๋“œ ๋ ˆํฌ์ง€ํ† ๋ฆฌ์ž…๋‹ˆ๋‹ค.

Notifications You must be signed in to change notification settings

LikeLion-12th-SKHU/LikeLion-12th-TEAM05-FE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

54 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๋ฐฐ์šด์ 

๋ฐฑ์—”๋“œ ์Šคํ‚ค๋งˆ DTO๋ฅผ ํƒ€์ž…์Šคํฌ๋ฆฝํŠธ ํ˜•ํƒœ๋กœ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋‹ค. penapi-typescript๋Š” ์Šค์›จ๊ฑฐ๋ฅผ ์ฝ๊ณ  ๋ฐฑ์—”๋“œ์˜ ์‘๋‹ต์„ typescriptํ˜•ํƒœ๋กœ ๋ฐ”๊ฟ”์ค€๋‹ค.

npx openapi-typescript ${schema docs url} --output schema.ts

์ด์ œ axios์— ์ œ๋„ค๋ฆญ ํ˜•ํƒœ๋กœ APIRequest,APIResponse๋ฅผ ๊ฑธ์–ด์ค„ ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿฌ๋ฉด ์‘๋‹ต ๊ฐ’์ด ์ž๋™์œผ๋กœ ์ถ”๋ก ๋˜์–ด์„œ ๋„ˆ๋ฌด ์ข‹์€ ๋“ฏ ํ•˜๋‹ค!

import { components } from '../../../../schema'
import { useInfiniteQuery } from '@tanstack/react-query'
import { axiosClient } from '@/services'

type APIResponse =
  components['schemas']['ApiResponseTemplateCurationListResDto']

์ฟผ๋ฆฌ์™€ mutation์€ 1๋Œ€1๋กœ ๋Œ€์‘ํ•˜๋Š”๊ฒŒ ๋ฐ”๋žŒ์งํ•œ ๊ฒƒ ๊ฐ™๋‹ค. queryํ•จ์ˆ˜์™€ ์ฟผ๋ฆฌ,mutation์„ ๋‘˜ ๋‹ค exportํ•ด์„œ ์“ธ ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋ฉด ๋” ์‘์ง‘๋„ ์žˆ์ง€ ์•Š์„๊นŒ

๋งต์„ ์“ฐ๋Š” ๊ฑด ๋„ˆ๋ฌด ์–ด๋ ต๋‹ค. ์ฝ”๋“œ๊ฐ€ ๋”๋Ÿฌ์›Œ์ง€๊ณ  useEffect๊ฐ€ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋น„๋Œ€ํ•ด ์งˆ ์ˆ˜๋ฐ–์— ์—†๋Š”๋ฐ, ๋ฐฉ๋ฒ•์„ ์ฐพ๋‹ค๊ฐ€ DI๋ฅผ ๊ฐœ๋…์„ ๋ดค๋‹ค.

๊ตฌ๊ธ€ ๋งต -> ๋„ค์ด๋ฒ„ ๋งต์œผ๋กœ ๋„ค์ด๋ฒ„ ๋งต -> ์นด์นด์˜ค ๋งต์œผ๋กœ ์š”๊ตฌ์‚ฌํ•ญ์ด ๋ฐ”๋€Œ๋ฉด ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋”๋Ÿฌ์›Œ์ง„ ์ฝ”๋“œ๋ฅผ ๋œฏ์„ ์ˆ˜ ๋ฐ–์— ์—†๋‹ค.

์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๋ฉด ์ ์ ˆํ•œ ์ถ”์ƒํ™”์™€ ์ง€๋„์— ๋Œ€ํ•œ DI๋ฅผ ์ฃผ์ž…ํ•ด์ฃผ๋ฉด ๋˜๋Š”๋ฐ, ํ•˜๋‚˜ํ•˜๋‚˜ ํ’€์–ด๊ฐ€๋ณด์ž..!

์—๋Ÿฌ๋ฐ”์šด๋”๋ฆฌ์™€ Suspense๋กœ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ฌด์ง€์„ฑ ๊ฐ์‹ธ๋Š” ๊ฒŒ ์ข‹์€๊ฑธ๊นŒ? ๋‚ด๊ฐ€ ํšจ๊ณผ์ ์œผ๋กœ ์—๋Ÿฌ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ณ ์žˆ๋Š”๊ฑด์ง€? ์„ ์–ธ์ ์ด๋ผ๋Š” ํ•จ์ •์— ๋น ์ ธ์„œ ๋ถˆํ•„์š”ํ•˜๊ฒŒ ๋ž˜ํ•‘์„ ํ•˜๋Š”๊ฒŒ ์•„๋‹์ง€ ๊ณ ๋ฏผ์ด ๋œ๋‹ค.

๋ฌดํ•œ์Šคํฌ๋กค์€ ์ด์ œ ์ต์ˆ™ํ•ด์กŒ๋‹ค..๋ฟŒ๋“ฏ(!)

tanstack-router๋ฅผ ์จ๋ดค๋‹ค. type-safeํ•˜๊ฒŒ ๋ผ์šฐํŒ…์„ ๋งŒ๋“ค์–ด์ฃผ๊ณ  ์ ์ ˆํžˆ ํƒ€์ž… ์ถ”๋ก , ํƒ€์ž… ์—๋Ÿฌ๋ฅผ ๋ฑ‰์–ด์ค˜์„œ ๋„ˆ๋ฌด ํŽธํ•˜๊ณ  ์ข‹๋‹ค. ๊ทธ๋ฆฌ๊ณ  query-stringํ˜•ํƒœ๋กœ ๋„˜๊ธธ ์ˆ˜๋„ ์žˆ๊ณ , ์„ ์–ธ์ ์œผ๋กœ private-route์ฒ˜๋ฆฌ๋„ ํ•  ์ˆ˜ ์žˆ์–ด์„œ ์ข‹๋‹ค

์•„๋งˆ ๋‹ค์Œ react์˜ router๋Š” tanstack-router๊ฐ€ ์งฑ์„ ๋จน์ง€ ์•Š์„๊นŒ..?

About

๐Ÿฆ ๋ฉ‹์Ÿ์ด์‚ฌ์ž์ฒ˜๋Ÿผ 12๊ธฐ SKHU ํ•ด์ปคํ†ค 5ํŒ€ ํ”„๋ก ํŠธ์—”๋“œ ๋ ˆํฌ์ง€ํ† ๋ฆฌ์ž…๋‹ˆ๋‹ค.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published