• this.props.children undefined

    this.props.children undefined

    You can’t access the children of your component through this.props.children. this.props.children designates the children being passed onto you by the owner:

    1. var App = React.createClass({
    2. componentDidMount: function() {
    3. // This doesn't refer to the `span`s! It refers to the children between
    4. // last line's `<App></App>`, which are undefined.
    5. console.log(this.props.children);
    6. },
    7. render: function() {
    8. return <div><span/><span/></div>;
    9. }
    10. });
    11. ReactDOM.render(<App></App>, mountNode);

    To access your own subcomponents (the spans), place refs on them.