Passing props to every children

Posted on Wednesday · March 06 2019 · 09:15 PM | 69 words · 1 min read

The problem

You have a ⚛ higher order component(HoC) like this:


You need to pass the prop color inside the children of the Parent component.

cloneElement to the rescue

One straight forward solution as described here is to clone the children and inject our desired props!

injected props

There was another approach using context with some caveats, but the bottom line is context and props are just not the same thing.