<star />
function as a child ๋ณธ๋ฌธ
728x90
function as a child ๋ ์ปดํฌ๋ํธ์ ์์์ผ๋ก ํจ์๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์.
๋ฆฌ์กํธ์์๋ ๊ธฐ๋ณธ์ ์ผ๋ก ํ์ ์ปดํฌ๋ํธ๋ค์ children ์ด๋ผ๋ prop ์ผ๋ก ์ ๋ฌํด ์ฃผ๋๋ฐ,
children ์ผ๋ก ์ปดํฌ๋ํธ ๋์ ํจ์๋ฅผ ์ฌ์ฉํ์ฌ ์๋์ ๊ฐ์ด ์ฌ์ฉํ ์ ์์.
// children ์ด๋ผ๋ prop ์ ์ง์ ์ ์ธํ๋ ๋ฐฉ์
<Info children={nickname => <h2>๋ณ๋ช
: {nickname}</h2>} />
// Info ์ปดํฌ๋ํธ๋ก ๊ฐ์ธ์ children ์ผ๋ก ๋ง๋๋ ๋ฐฉ์
<Info>{nickname=> <h2>๋ณ๋ช
: {nickname}</h2>}</Info>
728x90
'React ๐' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Provider value ์์ ์ฃผ์ํด์ผ ํ ์ฌํญ (0) | 2022.12.05 |
---|---|
์ปจํ ์คํธ (0) | 2022.12.04 |
๋ฆฌ์กํธ์ ํฉ์ฑ๊ณผ ์์ (0) | 2022.12.03 |
State ๋์ด์ฌ๋ฆฌ๊ธฐ (0) | 2022.12.01 |
๋ฆฌ์กํธ์ ํผ (0) | 2022.11.30 |
Comments