Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//fb.me/react-0.14.3.js"></script>
<script src="//fb.me/react-dom-0.14.3.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div id="container"></div>
</body>
</html>
 
.prompt { margin-bottom: 20px; }
 
var ChildComponent = React.createClass({
  render: function() {
    return (
      <div>
        <div className="prompt">Add a click handler to this button so that when clicked, performMagic is called in the parent component.</div>
        <button>Do Magic</button>
      </div>
    );
  }
});
var ParentComponent = React.createClass({
  performMagic: function() {
    alert('TAADAH!');
  },
  render: function() {
    return (
      <div>
        <ChildComponent />
      </div>
    );
  }
});
ReactDOM.render(
  <ParentComponent />,
  document.getElementById('container')
);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers