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