Props object
A React component is being passed a single argument: an object containing various properties that we call props. By default, it is empty. Any data passed by the consumer as an attribute lives as a prop in the props object.
function Home(props) {} // props.x
function Home({ x }) {} // x
<Home x={3} />
the children prop
When the consumer nests some elements inside the component, React provides such elements to the component, as a single prop called children
.
<Container>
<div>Hello</div>
<div>World!</div>
</Container>
function Container({ children }) {}
children
is a ReactNode
, even when it is a set of adjacent elements, aka an array of ReactElement
.