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=><ListItemtext={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 🥂
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.
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 🥂
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. :)Gotcha! Thanks for clarification.