-
-
Save kylpo/c596a4f713cd0171bc3d19f42e4f1ce2 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 { | |
componentDidMount() { | |
console.log('Cloning Mount') | |
} | |
render() { | |
console.log('Cloning Render') | |
const { children, ...propsToPass } = this.props | |
const child = React.Children.only(children) | |
console.log('ChildProps: ', child.props) | |
return React.cloneElement(child, propsToPass) | |
} | |
} | |
class Div extends React.Component { | |
static defaultProps = { | |
bye: 'bye' | |
} | |
componentDidMount() { | |
console.log('Div Mount') | |
} | |
render() { | |
console.log('Div Render') | |
return ( | |
<div>{this.props.children}</div> | |
) | |
} | |
} | |
export default class App extends React.Component { | |
render() { | |
return ( | |
<Cloning_> | |
<Div hi="hi" /> | |
</Cloning_> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment