πŸ“š Reference


πŸ“œ Chapter


children

React.ReactChild

React.ReactElement

React.createElement

React.ReactNode


// ReactChild νƒ€μž…μ— string, number νƒ€μž…μ΄ ν¬ν•¨λ˜μ–΄ μžˆλ‹€.
type ReactNode = ReactChild | ReactFragment | ReactPortal | boolean | null | undefined;

type ReactNode = ReactElement | string | number | ReactFragment | ReactPortal | boolean | null | undefined;

μ˜ˆμ‹œ


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;