Created
June 9, 2017 18:59
-
-
Save bolivier/bfa7d8e5642f541e6c1b5575640121a2 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/qowiceq
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script src="https://fb.me/react-15.1.0.js"></script> | |
<script src="https://fb.me/react-dom-15.1.0.js"></script> | |
<script id="jsbin-javascript"> | |
class C extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
logger(val) { | |
console.log(val) | |
} | |
render() { | |
return ( | |
React.createElement("div", null, | |
React.cloneElement( | |
this.props.children, | |
{ logger: this.logger } | |
) | |
) | |
); | |
} | |
} | |
class A extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return ( | |
React.createElement(C, null, | |
React.createElement(B, {val: 'foobar'}) | |
) | |
); | |
} | |
} | |
class B extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return ( | |
React.createElement("p", {onClick: this.props.logger.bind(this, this.props.val)}, | |
"click me!" | |
) | |
) | |
} | |
} | |
ReactDOM.render(React.createElement(A, null), document.getElementById("app")); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">class C extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
logger(val) { | |
console.log(val) | |
} | |
render() { | |
return ( | |
<div> | |
{React.cloneElement( | |
this.props.children, | |
{ logger: this.logger } | |
)} | |
</div> | |
); | |
} | |
} | |
class A extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return ( | |
<C> | |
<B val={'foobar'} /> | |
</C> | |
); | |
} | |
} | |
class B extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return ( | |
<p onClick={this.props.logger.bind(this, this.props.val)}> | |
click me! | |
</p> | |
) | |
} | |
} | |
ReactDOM.render(<A/>, document.getElementById("app"));</script></body> | |
</html> |
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 C extends React.Component { | |
constructor(props) { | |
super(props); | |
} | |
logger(val) { | |
console.log(val) | |
} | |
render() { | |
return ( | |
React.createElement("div", null, | |
React.cloneElement( | |
this.props.children, | |
{ logger: this.logger } | |
) | |
) | |
); | |
} | |
} | |
class A extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return ( | |
React.createElement(C, null, | |
React.createElement(B, {val: 'foobar'}) | |
) | |
); | |
} | |
} | |
class B extends React.Component { | |
constructor(props) { | |
super(props) | |
} | |
render() { | |
return ( | |
React.createElement("p", {onClick: this.props.logger.bind(this, this.props.val)}, | |
"click me!" | |
) | |
) | |
} | |
} | |
ReactDOM.render(React.createElement(A, null), document.getElementById("app")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment