Files
react.dev/tips/17-children-undefined.md
Ben Alpert fb46ad0356 Update docs to align with 0.12 better
- Rename React.renderComponent -> React.render
- Remove most references to transferPropsTo
2014-10-22 14:01:54 -07:00

806 B

id, title, layout, permalink, prev
id title layout permalink prev
children-undefined this.props.children undefined tips children-undefined.html references-to-components.html

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:

var App = React.createClass({
  componentDidMount: function() {
    // This doesn't refer to the `span`s! It refers to the children between
    // last line's `<App></App>`, which are undefined.
    console.log(this.props.children);
  },

  render: function() {
    return <div><span/><span/></div>;
  }
});

React.render(<App></App>, mountNode);

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