We can utilize React.cloneElement in order to create new components with extended data or functionality.
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?
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.
I am wondering why does the syntax 'this.setState({selected})' (inside selectItem function) working correctly? Should it be 'this.setState({selected: selected})'?