-
-
Save kylpo/ab31af075ef1819d237db1ffb454ae1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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