๐ PropsWithChildren
type PropsWithChildren<P> = P & { children?: ReactNode };
1. generic ํ์ ๋งค๊ฐ๋ณ์ P๋ฅผ ๋ฐ์์จ๋ค
2. ํด๋น ํ์ ์ ReactNode ํ์ ์ children ์์ฑ์ ์ถ๊ฐํด์ค๋ค.
๐ PropsWithChildren ์ฌ์ฉํ๊ธฐ
PropsWithChildrenํ์ ์ ๋ง ๊ทธ๋๋ก children์ ๊ฐ์ง props ํ์ ์ ์๋ฏธํ๋ค.
์ง์ children์ ํ์ ์ผ๋ก ๋ช ์ํด์ฃผ์ด์ผํ๋ ReactNode์๋ ๋ค๋ฅด๊ฒ children์ ํ์ ์ ์ค์ ํด์ค ํ์๊ฐ ์๋ค.
๐จ But, children ํ์ ์ด ์ต์ ๋์ด๋ค!
children์ ๋๊ฒจ์ฃผ์ง ์๊ณ ์ฌ์ฉํด๋, ์๋ฌ๊ฐ ๋ฐ์ํ์ง ์๋๋ค. (= React.FC ํ์ ์ ๋ฌธ์ ์ ๊ณผ ์ ์ฌ)
๋ฐ๋ผ์, PropsWithChildren์ ์ฌ์ฉํด์ผํ๋ ๊ฒฝ์ฐ children์ ์ต์ ๋๋ก ์ฌ์ฉํ ๊ฒฝ์ฐ์๋ง ์ฌ์ฉํ๊ณ , ํญ์ children์ ๋๊ฒจ์ค์ผํ๋ ๊ฒฝ์ฐ์๋ PropsWithChildren์ ์ฌ์ฉํ์ง ์๋๊ฒ ์ข์ ๊ฒ ๊ฐ๋ค.
Reference
https://velog.io/@kkojae91/PropsWithChildren๋-์์ ํ-ํ์ ์ผ๊น
๐ PropsWithChildren
type PropsWithChildren<P> = P & { children?: ReactNode };
1. generic ํ์ ๋งค๊ฐ๋ณ์ P๋ฅผ ๋ฐ์์จ๋ค
2. ํด๋น ํ์ ์ ReactNode ํ์ ์ children ์์ฑ์ ์ถ๊ฐํด์ค๋ค.
๐ PropsWithChildren ์ฌ์ฉํ๊ธฐ
PropsWithChildrenํ์ ์ ๋ง ๊ทธ๋๋ก children์ ๊ฐ์ง props ํ์ ์ ์๋ฏธํ๋ค.
์ง์ children์ ํ์ ์ผ๋ก ๋ช ์ํด์ฃผ์ด์ผํ๋ ReactNode์๋ ๋ค๋ฅด๊ฒ children์ ํ์ ์ ์ค์ ํด์ค ํ์๊ฐ ์๋ค.
๐จ But, children ํ์ ์ด ์ต์ ๋์ด๋ค!
children์ ๋๊ฒจ์ฃผ์ง ์๊ณ ์ฌ์ฉํด๋, ์๋ฌ๊ฐ ๋ฐ์ํ์ง ์๋๋ค. (= React.FC ํ์ ์ ๋ฌธ์ ์ ๊ณผ ์ ์ฌ)
๋ฐ๋ผ์, PropsWithChildren์ ์ฌ์ฉํด์ผํ๋ ๊ฒฝ์ฐ children์ ์ต์ ๋๋ก ์ฌ์ฉํ ๊ฒฝ์ฐ์๋ง ์ฌ์ฉํ๊ณ , ํญ์ children์ ๋๊ฒจ์ค์ผํ๋ ๊ฒฝ์ฐ์๋ PropsWithChildren์ ์ฌ์ฉํ์ง ์๋๊ฒ ์ข์ ๊ฒ ๊ฐ๋ค.
Reference
https://velog.io/@kkojae91/PropsWithChildren๋-์์ ํ-ํ์ ์ผ๊น