Arrays of Children: ReactNode vs ReactElement[]
What you'll learn: How to type props when you need an array of child elements versus accepting any renderable content including arrays.
The Core Distinction
When your component expects multiple children in array form, you have two typing choices that mean different things:
ReactNode— accepts anything renderable, including arrays naturally (strings, numbers, elements, nested arrays, fragments)ReactElement[]— explicitly requires an array of JSX elements only
Think of ReactNode as "I'll take whatever you give me, including arrays" while ReactElement[] is "I need exactly an array of JSX elements, no primitives allowed."
When to Use Each
Use ReactNode when:
interface TabsProps {
children: ReactNode; // Accepts <Tab/>, arrays, fragments, anything
}
This handles <Tabs><Tab/><Tab/></Tabs> (React wraps multiple children in an array automatically) and direct arrays.
Use ReactElement[] when:
interface StrictListProps {
items: ReactElement[]; // ONLY an array of elements
}
// Usage must be explicit
<StrictList items={[<Item key="1"/>, <Item key="2"/>]} />
This enforces homogeneous element arrays and won't accept strings or numbers mixed in.
The Practical Difference
ReactNode is permissive — it includes ReactElement[] as one possibility among many. ReactElement[] is strict — it demands an actual array prop containing only JSX elements. Use the stricter type when you need to .map() over elements and perform element-specific operations like cloning.
Key Takeaway: ReactNode accepts arrays naturally but allows any renderable content; ReactElement[] explicitly requires an array of JSX elements only, giving you type-safe array operations at the cost of flexibility.