Capítulo 15 de 116
Props are a component's only argument — a read-only object passed down from a parent that lets parent and child evolve independently, the same role function arguments play for ordinary functions.
<Avatar person={{...}} size={100} />); any JS value works, including objects/arrays/functions.function Avatar({ person, size }) {} — equivalent to receiving one props object and reading props.person/props.size.function Avatar({ size = 100 }) — applies when the prop is missing or explicitly undefined. Passing null or 0 does not trigger the default.<Avatar {...props} /> forwards every prop without listing names — convenient when a wrapper doesn't touch any prop directly, but overusing it usually signals you should split the component or use children instead.children prop: JSX nested between a component's opening/closing tags (<Card><Avatar /></Card>) arrives as props.children on Card. This is the mechanism behind every generic wrapper (panels, layouts, grids) that doesn't need to know what it's wrapping.function Card({ children }) {
return <div className="card">{children}</div>;
}
// usage:
<Card>
<Avatar person={{ name: 'Katsuko Saruhashi', imageId: 'YfeOqp2' }} size={100} />
</Card>
Card never needs to know what it's wrapping — the nested <Avatar /> JSX arrives as Card's children prop.{ person, size }) is the idiomatic way to read props — don't reach for the whole props object unless you genuinely need it.size = 100) only kicks in for missing/undefined, not for falsy-but-present values like 0 or null — a common source of "why isn't my default applying" bugs.children is the pattern for building generic layout/wrapper components — reach for it instead of heavy spread-forwarding when a component's job is just "wrap arbitrary content."children decouples a component's render-tree position from its module-import location.{} syntax used to pass non-string prop values.