π Reference
π Chapter
ReactNode
**λΒ **children
**μμ±μ νμ
μΌλ‘ κ°μ₯ λ§μ΄ μ¬μ©νλ νμ
μ΄λ€.// ReactChild νμ
μ string, number νμ
μ΄ ν¬ν¨λμ΄ μλ€.
type ReactNode = ReactChild | ReactFragment | ReactPortal | boolean | null | undefined;
type ReactNode = ReactElement | string | number | ReactFragment | ReactPortal | boolean | null | undefined;
ReactNode
**νμ
μΒ **jsx
**λ΄μμ μ¬μ©ν μ μλ λͺ¨λ μμμ νμ
μ μλ―Ένλ€.string
,Β null
,Β **undefined
**λ±μ ν¬ν¨νλ κ°μ₯ λμ λ²μλ₯Ό κ°λ νμ
μ΄λ€.ReactNode
νμ
μ ν΄λμ€ μ»΄ν¬λνΈμ render
ν¨μκ° κΈ°λ³Έμ μΌλ‘ 리ν΄νλ νμ
μ΄λ€.ReactElement
μΈν°νμ΄μ€λ₯Ό λ¦¬ν΄ νλ€.const App = () => {
return (
<div className="App">
<Wrapper>
{/* κ³Όμ° children μμμ νμ
μ 무μμΌκΉμ? */}
<div>Hello, world!</div>
</Wrapper>
</div>
);
};
type WrapperProp = {
// children: React.ReactChild;
// children: React.ReactElement;
// children: JSX.Element;
// children: React.ReactChildren;
// children: React.ReactNode;
// ...μΌμμμ!! ...
};
const Wrapper = ({ children }: WrapperProp) => {
return (
<div className="Wrapper">
<div>{children}</div>
</div>
);
};
export default App;