You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
803 B

---
id: children-undefined
title: this.props.children undefined
layout: tips
permalink: children-undefined.html
prev: references-to-components.html
next: use-react-with-other-libraries.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:
```js
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);
```
For a more sophisticated example, refer to the last example on the [front page](/).