React.Children.map
Example of React.Children.map for "Introduction to React"
by dimeget
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>
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script></head><body>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div></body></html>
JavaScript 1.7
var MyComponent = React.createClass({
render: function() {
React.Children.map(this.props.children, function(child){
console.log(child)
});
return (
<div>
{this.props.name}
</div>
);
}
});
React.render(<MyComponent name="frodo" >
<p key="firsty">a child</p>
<p key="2">another</p>
</MyComponent>, document.getElementById('container'));