[React Fundamentals] Accessing Child Properties
When you're building your React components, you'll probably want to access child properties of the markup.
In Angular, it is transcludion:
<div>
<ng-transculde></ng-transclude>
</div>
In React, it is:
{this.props.children}
It means, use whatever pass in my component:
import React from 'react';
export default class App extends React.Component {
render() {
return (
<Button>I <Heart /> React</Button>
)
}
}
class Button extends React.Component{
render() {
return (
<button>{this.props.children}</button>
)
}
}
const Heart = () => <span>Love</span>;
So we pass <Heart /> into Button component, so in Button component, we use {this.user.props}
[React Fundamentals] Accessing Child Properties的更多相关文章
- [React] React Fundamentals: Accessing Child Properties
When you're building your React components, you'll probably want to access child properties of the m ...
- [React Fundamentals] Introduction to Properties
This lesson will teach you the basics of setting properties in your React components. class App exte ...
- [React] React Fundamentals: transferPropsTo
the transferPropsTo method lets you easily push properties into your components to easily customize ...
- [React Fundamentals] State Basics
State is used for properties on a component that will change, versus static properties that are pass ...
- [React] React Fundamentals: State Basics
State is used for properties on a component that will change, versus static properties that are pass ...
- [React Fundamentals] Composable Components
To make more composable React components, you can define common APIs for similar component types. im ...
- [React Fundamentals] Component Lifecycle - Updating
The React component lifecycle will allow you to update your components at runtime. This lesson will ...
- [React Fundamentals] Component Lifecycle - Mounting Usage
The previous lesson introduced the React component lifecycle mounting and unmounting. In this lesson ...
- [React Fundamentals] Component Lifecycle - Mounting Basics
React components have a lifecycle, and you are able to access specific phases of that lifecycle. Thi ...
随机推荐
- Django提供后台接口的跨域问题
--> Django跨域 当使用Django仅用来开发后端接口,为前端提供JSON数据的时候,不可避免的要接受前端的POST请求.虽然Django以其强大易用的特定使用很广泛,但在跨域问题上却让 ...
- POJ 3678 Katu Puzzle (2-SAT,常规)
题意:给出n个点,每个点上有一个数字可以0或1,然后给出m条限制,要求a和b两个点上的数字满足 a op b = c,op和c都是给定.问是否能够有一组解满足所有限制?(即点上的数字是0是1由你决定) ...
- ♫【jQuery插件】图片放大镜
JQZoom
- 【Java基础之容器】Iterator
Iterator: ->所有实现了Collection接口的容器类都有一个iterator方法用以返回一个实现了Iterator接口的对象 ->Iterator对象称作迭代器,用以方便的实 ...
- 【转】报错:Program "sh" not found in PATH
原文网址:http://www.cnblogs.com/SadNight/p/3406201.html (1) 报错:Program "sh" not found in PATH ...
- 【转】 当程序崩溃的时候怎么办 part-1
转自:http://www.tairan.com/archives/1006 有这样一种情形:当我们正在快乐的致力于我们的app时,并且什么看都是无比顺利,但是突然,坑爹啊,它崩溃了.(悲伤地音乐响起 ...
- java vm args
这个问题主要还是由这个问题 java.lang.OutOfMemoryError: Java heap space 引起的.第一次出现这样的的问题以后,引发了其他的问题.在网上一查可能是JAVA的堆栈 ...
- linux下判断网络是否连接
本文改写自网上的一个程序,原始程序中为阻塞式调用,而且有现成创建的过程,非常不利于集成到自己程序中,因此对原始程序进行改造,使其可以完成发送一个imcp包的方式来判断网络连通,只需要调用改进后的 bo ...
- Protobuf语言指南
Protobuf语言指南 l 定义一个消息(message)类型 l 标量值类型 l Optional 的字段及默认值 l 枚举 l 使用其他消息类型 l 嵌套类型 l 更新一个消息类型 ...
- js会飞的li标签
当点击左边的li标签的时候,这边的li标签飞到右边去,点击右边的li标签飞到左边来,并且有顺序 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...