The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Use React.cloneElement to Extend Functionality of Children Components

Use React.cloneElement to Extend Functionality of Children Components

2:14
We can utilize React.cloneElement in order to create new components with extended data or functionality.
Watch this lesson now
Avatar
egghead.io

We can utilize React.cloneElement in order to create new components with extended data or functionality.

Avatar
Lars-m

Up until now I really liked this series.
But does this example not breaks with the whole idea of React and the Virtual DOM?

Each time a button is clicked, all thee buttons must be cloned and the whole screen re-rendered.
That seems very in-efficient?

Avatar
Control

If your changes to the children do not rely on an updated state (similar to this lesson), you can make those changes in the componentWillMount() method so they only happen the first time the component is rendered. Subsequent renderings will already have the updated children.

In reply to Lars-m
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?