Skip to content

Instantly share code, notes, and snippets.

@smoidu
Created April 6, 2016 19:55
Show Gist options
  • Save smoidu/f0b014428d3a5a71d61d06346d9643c1 to your computer and use it in GitHub Desktop.
Save smoidu/f0b014428d3a5a71d61d06346d9643c1 to your computer and use it in GitHub Desktop.
es6 class and cloneElement
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