Created
April 6, 2016 19:55
-
-
Save smoidu/f0b014428d3a5a71d61d06346d9643c1 to your computer and use it in GitHub Desktop.
es6 class and cloneElement
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
const { Router, | |
Route, | |
IndexRoute, | |
Redirect, | |
Link, | |
IndexLink | |
} = ReactRouter | |
const StandardClass = class ComponentClass extends React.Component { | |
constructor(props) { | |
super(props); | |
this.props = {}; | |
} | |
render() { | |
return React.cloneElement(CreatedClass, this.state); | |
} | |
} | |
const CreatedClass = React.createClass({ | |
render() { | |
return ( | |
<div> | |
<h1>React Router Playground</h1> | |
</div> | |
) | |
} | |
}) | |
React.render(( | |
<Router> | |
<Route path="/" component={StandardClass}/> | |
</Router> | |
), document.getElementById('app')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment