Skip to content

Instantly share code, notes, and snippets.

@kylpo

kylpo/block12.jsx Secret

Created Jun 21, 2017
Embed
What would you like to do?
class Cloning_ extends React.Component {
render() {
console.log('Cloning Render')
const { children, ...propsToPass } = this.props
const child = React.Children.only(children)
console.log('passProps', propsToPass)
return React.cloneElement(child, propsToPass)
}
}
class PureComponent extends React.PureComponent {
render() {
console.log('PureComponent Render')
return (
<div />
)
}
}
export default class App extends React.Component {
state = {}
componentDidMount() {
setTimeout(() => this.setState({hi: 'hi'}), 2000)
}
render() {
return (
<Cloning_ hi='hi'>
<PureComponent />
</Cloning_>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.