type
-
React.ts PropsWithChildren
PropsWithChildren๋ค์ด๊ฐ๋ฉฐ๋ฆฌ์กํธ(React.ts)์์ ์ฌ์ฉํ ์ ์๋ PropsWithChildren ํ์ ์ ๋ํด ์ ๋ฆฌํด๋ณธ๋ค.์ด ํ์ ์ ๋ฆฌ์กํธ์ ํ์ ์คํฌ๋ฆฝํธ๋ฅผ ํจ๊ป ์ฌ์ฉํ ๋ ์ฌ์ฉํ ์ ์๋ค. PropsWithChildren๊ฐ๋ ํ์ ์คํฌ๋ฆฝํธ(TypeScript)์์ ๋ฆฌ์กํธ ์ปดํฌ๋ํธ์ ์์ ์์(children)๋ฅผ ํ์ฉํ๊ณ ์ ํ ๋ ์ฌ์ฉํ๋ ์ ํธ๋ฆฌํฐ ํ์ ๋ณดํต ์ปดํฌ๋ํธ์ ์ ๋ฌ๋๋ ๊ธฐ๋ณธ props ์ธ์๋ ์์ ์์๋ฅผ ํฌํจํ ์ ์์ ๋ ์ ์ฉํ๊ฒ ์ฌ์ฉ๋๋ค.PropsWithChildren ํ์ ์ ์ปดํฌ๋ํธ๊ฐ ์์ ์์๋ฅผ ๊ฐ์ง ์ ์๋๋ก ๋ช ์ํ๋ฉฐ, children์ ๋ช ์์ ์ผ๋ก ์ ์ํ์ง ์๊ณ ๋ ์ฌ์ฉํ ์ ์๋๋ก ํด์ค๋ค. ์ฌ์ฉ ์์ import { PropsWithChildren } from ..
0 2024.11.05 -
TypeScript ์ธํฐํ์ด์ค(Interface)
์ธํฐํ์ด์ค(Interface)๋ค์ด๊ฐ๋ฉฐํ์ ์คํฌ๋ฆฝํธ(TypeScript)์ ์ธํฐํ์ด์ค(Interface) ํ์ ์ ๋ํด ์ ๋ฆฌํด๋ณธ๋ค. ์ธํฐํ์ด์ค(Interface)๊ฐ๋ ๊ฐ์ฒด์ ๊ตฌ์กฐ๋ฅผ ์ ์ํ๋ ๋ฐ ์ฌ์ฉ๋๋ ํ์ ๊ฐ์ฒด๊ฐ ๊ฐ์ ธ์ผ ํ ์์ฑ, ๊ทธ ์์ฑ์ ํ์ , ๊ทธ๋ฆฌ๊ณ ๋ฉ์๋๋ฅผ ์ง์ ํ ์ ์๋ค.์๋ฐ์คํฌ๋ฆฝํธ์๋ ์กด์ฌํ์ง ์์ผ๋ฉฐ, ํ์ ์คํฌ๋ฆฝํธ์์ ์ฌ์ฉ ๊ฐ๋ฅํ๋ค.์ฝ๋์ ๊ฐ๋ ์ฑ ๋ฐ ์ ์ง๋ณด์๋ฅผ ์ฝ๊ฒ ํ๊ณ , ํ์ ์์ ์ฑ์ ๋์ฌ์ค๋ค. ์ฃผ์ ๊ธฐ๋ฅ๊ฐ์ฒด๊ฐ ํน์ ์์ฑ๋ค์ ๋ฐ๋์ ๊ฐ์ง๊ณ ์์ด์ผ ํ๋ ๊ตฌ์กฐ๋ฅผ ์ ์ํ ์ ์๋ค.ํน์ ์์ฑ์ ์ ํ์ ์ผ๋ก ํฌํจ๋ ์ ์๋๋ก ์ ์ํ ์ ์๋ค.์) age?: number;ํจ์์ ๋งค๊ฐ๋ณ์์ ๋ฐํ๊ฐ์ ํ์ ๋ ์ธํฐํ์ด์ค๋ก ์ ์ํ ์ ์๋ค.ํด๋์ค๋ ์ธํฐํ์ด์ค๋ฅผ implements ํค์๋๋ฅผ ํตํด ๊ตฌํํ ์ ์๋ค...
0 2024.10.12 -
TypeScript ์ ๋ค๋ฆญ(Generic)
์ ๋ค๋ฆญ(Generic)๋ค์ด๊ฐ๋ฉฐํ์ ์คํฌ๋ฆฝํธ(TypeScript)์์ ์ฌ์ฉ๋๋ ์ ๋ค๋ฆญ(Generic)์ ๋ํด ์ ๋ฆฌํด๋ณธ๋ค. ์ ๋ค๋ฆญ(Generic)๊ฐ๋ ์ ์ฐํ๋ฉด์๋ ํ์ ์์ ์ฑ์ ์ ๊ณตํ๋ ๋ฐฉ๋ฒ์ ๋ค๋ฆญ์ ์ฌ์ฉํ๋ฉด ํจ์๋ ํด๋์ค๋ฅผ ๋ค์ํ ํ์ ๊ณผ ํจ๊ป ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, ํ์ ์ ๊ตฌ์ฒด์ ์ผ๋ก ์ง์ ํ ์ ์๋ค. ์ ๋ค๋ฆญ์ ํ์์ฑ์๋์ insertAtBeginning ํจ์๋ฅผ ๋ณด์.์ด ํจ์๋ ๋ฐฐ์ด๊ณผ ๊ฐ์ ๋งค๊ฐ๋ณ์๋ก ๋ฐ์, ๊ฐ์ด ๋ฐฐ์ด์ ๋งจ ์์ ์ถ๊ฐ๋ ์๋ก์ด ๋ฐฐ์ด์ ๋ฐํํ๋ค.function insertAtBeginning(array: any[], value: any) { return [value, ...array];}const updatedArray = insertAtBeginning(demoArray, -1); // [-1,..
0 2024.08.20