码迷,mamicode.com
首页 > 数据库 > 详细

[React Fundamentals] Accessing Child Properties

时间:2016-08-15 06:39:45      阅读:161      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5771547.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!