zoukankan      html  css  js  c++  java
  • [React Fundamentals] Owner Ownee Relationship

    The owner-ownee relationship is used to designate a parent-child relationship with React components as it differs from the DOM relationship.

    import React from 'react';
    
    export default class App extends React.Component {
        constructor(){
            super(); //This is going to give us our context for this within our component
            this.update = this.update.bind(this);
            this.state = {
                txt: 'State',
                count: 1
            }
        }
        update(e){
            this.setState({
                txt: e.target.value
            })
        }
        render() {
            return (
                <div>
                    <Widget txt={this.state.txt} update={this.update}></Widget>
                    <Widget txt={this.state.txt} update={this.update}></Widget>
                </div>
    
            )
        }
    }
    
    // "Widget" must be capitalized
    const Widget = (props) => {
        return (
            <div>
                <input type="text" onChange={props.update} />
                <span>Hello {props.txt}</span>
            </div>
        )
    }
  • 相关阅读:
    c#格林治时间实现
    K3WISE常用表
    读取单元格数据
    水晶报表使用方法
    vs2010下使用sqlite
    C#执行EXE程序
    SQLLITE HELPER
    SQL LITE安装
    C#多线程
    VS2012 快捷键
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5771546.html
Copyright © 2011-2022 走看看