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}

  • 相关阅读:
    python django day 1
    C# 日常
    C# NPOI使用
    SharpZipLib 压缩ZIP导出
    JSON劫持
    跨站请求伪造CSRF或XSRF
    跨站脚本XSS安全
    会话窃取
    Cookie
    Promise -ES6
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5771547.html
Copyright © 2011-2022 走看看