React Base Fiddle (JSX)
Starting point for creating JSFiddles with React. This uses React with Addons.
by Eric
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/react-with-addons.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
CSS
.item {
width: 50px;
height: 50px;
border: 1px solid #000000;
}
JavaScript 1.7
var Example = React.createClass({
propTypes: {
children: React.PropTypes.node,
},
componentDidMount() {
this.lookAtChildren();
},
render: function() {
return (
<section>
{this.props.children}
</section>
);
},
componentDidUpdate: function() {
this.lookAtChildren();
},
lookAtChildren: function() {
console.log('isMounted', this.isMounted());
React.Children.forEach(this.props.children, (child) => {
console.log(React.findDOMNode(child));
});
}
});
React.render(<Example>{[<div key="0" className="item" />, <div key="1" className="item" />]}</Example>, document.getElementById('container'));