DEV Community

Discussion on: Render Props and Higher Order Components

Collapse
 
kepta profile image
Kushan Joshi • Edited

Great article K, really contrasts HOC and render props.
Just a minor concern, I am not sure whether the first example you posted qualifies as a render props.

<List>
  {data.map(i => <ListItem text={i}/>)}
</List>

As you said a render prop is a function which the child component invokes to figure out how to render dynamically. However in the example above you are not passing any function to child component, instead you are passing a simple array of react elements.
Cheers 🥂

Collapse
 
kayis profile image
K

Thanks!

This wasn't an example of a render prop but of general dependency injection.

I tried to show how DI leads to RP. :)

"you said a render prop is a function which the child component invokes"

No no, the children will be returned by this function, the parent invokes it, because the parent gets it passed via the render prop. :)

Collapse
 
kepta profile image
Kushan Joshi

Gotcha! Thanks for clarification.