Alex
Alex

Reputation: 2780

What is the difference in behaviour between props.children and a regular prop?

What is the difference (if any) in the way React handles 'props.children' versus if I were simply to add the same JSX in as a prop? Is this just simply for better presentation of code?

<Parent>
    <Child />
    <Child />
</Parent>

vs.

<Parent otherChildren={<><Child /><Child /></>} />

Upvotes: 1

Views: 131

Answers (1)

Mos&#232; Raguzzini
Mos&#232; Raguzzini

Reputation: 15821

The main difference is that props.children can be declared both in props and enclosed in JSX tag of the component. Beside that, the behavior is exactly the same.

Upvotes: 1

Related Questions