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.
17 lines
620 B
17 lines
620 B
11 years ago
|
---
|
||
|
id: children-prop-type
|
||
|
title: Type of the children prop
|
||
11 years ago
|
layout: cookbook
|
||
11 years ago
|
permalink: children-prop-type.html
|
||
11 years ago
|
prev: style-prop-value-px.html
|
||
|
next: controlled-input-null-value.html
|
||
11 years ago
|
---
|
||
|
|
||
|
### Problem
|
||
|
You get errors while manipulating `this.props.children` inside a component.
|
||
|
|
||
|
### Solution
|
||
11 years ago
|
Usually, `children` is an array of components. To save an extra array allocation, it returns the component itself when there's only one.
|
||
11 years ago
|
|
||
11 years ago
|
This means accessing, for example, `this.props.children.length` might be misleading, as it could either be the `length` property of the array of children, or that of a single string component.
|