๐ŸšจCannot find name 'SetAtom'.๐Ÿšจ

ํ˜œํ˜œยท2023๋…„ 11์›” 12์ผ
0

Error Note

๋ชฉ๋ก ๋ณด๊ธฐ
8/19
post-thumbnail
post-custom-banner

โ—๋ฌธ์ œ ๋‚ด์šฉ

Jotai๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค๊ฐ€ ๋‚˜ํƒ€๋‚œ ์˜ค๋ฅ˜.

export interface MatchingFormProps {
  title: string;
  isRequired: boolean;
  placeholder: string;
  maxLength: number;
  handler: SetAtom<[SetStateAction<string>], void>;
  charCount: number;
}

์ปดํฌ๋„ŒํŠธ์— useSetAtom(...) ํ•จ์ˆ˜๋ฅผ ๋„˜๊ฒจ์ฃผ๊ณ  ์‹ถ์–ด์„œ props ํƒ€์ž…์„ ์ •์˜ํ•ด ๋ณด์•˜๋Š”๋ฐ, ์—ฌ๊ธฐ์„œ SetAtom์ด๋ผ๋Š” ํƒ€์ž…์ด resolve ๋˜์ง€ ์•Š์•„์„œ ๋‚˜ํƒ€๋‚˜๋Š” ์˜ค๋ฅ˜์˜€๋‹ค. SetStateAction ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” Jotai ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์•ˆ์— ๋“ค์–ด ์žˆ๋Š”๋ฐ, SetAtom ํƒ€์ž…์€ ๋“ค์–ด์žˆ์ง€ ์•Š์•˜๋‹ค...!

โš’๏ธ ๋ฌธ์ œ ํ•ด๊ฒฐ

type SetAtom<Args extends any[], Result> = (...args: Args) => Result;

SetAtom ํƒ€์ž…์„ ์ง์ ‘ ์ •์˜ํ•ด์„œ ์‚ฌ์šฉํ•ด์ฃผ๋ฉด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค. ์ธ์ž๋กœ ์–ด๋–ค ํƒ€์ž…์ด๋“  ๋“ค์–ด์˜ฌ ์ˆ˜ ์žˆ๊ณ , Result๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜ ํƒ€์ž…์œผ๋กœ SetAtom์„ ์ •์˜ํ•œ ๊ฒƒ์ด๋‹ค. ์•„๋ž˜์˜ ์Šคํƒ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ ๋งํฌ์—์„œ ๋งŽ์€ ๋„์›€์„ ๋ฐ›์•˜๋‹ค.

๐Ÿ™‡โ€โ™‚๏ธ ์ฐธ๊ณ ์ž๋ฃŒ

TypeScript Error: Cannot Find Name 'SetAtom' When Using Jotai

profile
์‰ฝ๊ฒŒ๋งŒ์‚ด์•„๊ฐ€๋ฉด์žฌ๋ฏธ์—†์–ด๋น™๊ณ 
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€