Skip to content

Instantly share code, notes, and snippets.

@kylpo
Created June 21, 2017 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylpo/ab31af075ef1819d237db1ffb454ae1a to your computer and use it in GitHub Desktop.
Save kylpo/ab31af075ef1819d237db1ffb454ae1a to your computer and use it in GitHub Desktop.
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