博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[React] React Fundamentals: Accessing Child Properties
阅读量:6717 次
发布时间:2019-06-25

本文共 1185 字,大约阅读时间需要 3 分钟。

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 the  to manipulate them.

 

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.

 

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.children will be the single child component itself without the array wrapper. This saves an array allocation.

 

    
React Lesson 6: Accessing Child Properties

 

App has two children BButton and BHeart, all thoes chilren come thought from {this.props.children}.

 

If you don't have {this.props.children}:

var BButton = React.createClass({       render: function() {           return (             No passed in!           );       }    });

We end up with this: 

 

[Notice:] Just remeber when give class to the render elements, we need to use 'className' not 'class'.

转载地址:http://kpkmo.baihongyu.com/

你可能感兴趣的文章
c++opencv项目移植到Android(Mat—》IplImage*)
查看>>
嵌入式linux------SDL移植(am335x下显示yuv420)
查看>>
当vcenter是linux版本的时候Sysprep存放路径
查看>>
代码管理(五)git 删除分支
查看>>
[学习笔记]Spring依赖注入
查看>>
网络虚拟化(SDN,NFV..)和企业骨干网的演化
查看>>
怎么确保站点的可用性
查看>>
我的第一个android应用——装逼神器《微博尾》
查看>>
[3] MQTT,mosquitto,Eclipse Paho---怎样使用 Eclipse Paho MQTT工具来发送订阅MQTT消息?
查看>>
oracle 之 控制oracle RAC 进行并行运算
查看>>
jsTree插件简介(三)
查看>>
2D Rotated Rectangle Collision
查看>>
PHP error_reporting() 函数
查看>>
SpringBoot(十)-- 整合MyBatis
查看>>
查看三种MySQL字符集的方法
查看>>
django -- 多对多关系的实现
查看>>
with revoked permission android.permission.CAMERA
查看>>
Python在函数中使用*和**接收元组和列表
查看>>
115. Distinct Subsequences
查看>>
C++ 指针(不论什么一个指针本身的类型都是unsigned long int型)
查看>>