zoukankan      html  css  js  c++  java
  • [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}

  • 相关阅读:
    PHP install perl module
    PHP 静态页
    PHP对类的操作
    PHP Mysql操作。
    2020.7.16
    2020.7.19
    2020.7.14
    2020.7.12
    2020.7.17
    2020.7.10
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5771547.html
Copyright © 2011-2022 走看看