In principle children in React plays a similar role to slotted elements in DOM templates (Web Components) - but children isn't as powerful as Vue's scoped slots (or Svelte's named slots) which can bind external data into slotted elements.
Under the old terminology both div and a are "ownees" of the owner custom component.
I was trying to point out that custom components don't often use the children prop for elements nested by the owner because of their static nature. Often the component needs to render data into the fragment (much like a template) which requires a "function as child component", a render prop, or injected component.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In principle
children
in React plays a similar role toslotted
elements in DOM templates (Web Components) - butchildren
isn't as powerful as Vue's scoped slots (or Svelte's named slots) which can bind external data into slotted elements.For that purpose renderProps (or component injection) are used in React (example gist).
That might explain why the
children
prop is so infrequently used in contemporary React.Literally any React element which can have nested elements uses
children
prop.Just used children two times
a
useschildren
for 'test'div
useschildren
for the aboveUnder the old terminology both
div
anda
are "ownees" of the owner custom component.I was trying to point out that custom components don't often use the
children
prop for elements nested by the owner because of their static nature. Often the component needs to render data into the fragment (much like a template) which requires a "function as child component", a render prop, or injected component.