Skip to content

Instantly share code, notes, and snippets.

@kylpo

kylpo/block8.jsx Secret

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/2fc6dfa919e9bfd5d4cb69ad73b52e3c to your computer and use it in GitHub Desktop.
Save kylpo/2fc6dfa919e9bfd5d4cb69ad73b52e3c to your computer and use it in GitHub Desktop.
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