[React] ReactFundamentals: AccessingChildProperties

Source: Internet
Author: User
WhenyourebuildingyourReactcomponents, response. Parentcanreaditschildrenbyaccessingthespecialthis. props. childrenprop. this. props. childrenisanopaquedatastructure: use

When you're building your React components, you'll probably want to access child properties of the markup. parent can read its children by accessing the special this. props. children prop. this. props. children is an opaque data structure: use

When you're building your React components, you'll probably want to access child properties of the markup.

ParentCan read its children by accessing the specialthis.props.childrenProp.this.props.childrenIs an opaque data structure:Use the React. Children utilities to manipulate them.

Https://facebook.github.io/react/docs/multiple-components.html

This. props. children undefined

You can't access the children of your component throughthis.props.children.this.props.childrenDesignates the children beingPassed onto youBy the owner.

Https://facebook.github.io/react/tips/children-undefined.html

Type of the Children props

Usually, a component's children (this.props.children) Is an array of components. However, when there is only a single child,this.props.childrenWill be the single child component itselfWithout the array wrapper. This saves an array allocation.

Https://facebook.github.io/react/tips/children-props-type.html

    
     React Lesson 6: Accessing Child Properties    
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.