首页 > 数据库技术 > 详细

[React Fundamentals] Accessing Child Properties

时间:2016-08-15 06:39:10      阅读:294      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!