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>
)
}

[React Fundamentals] Owner Ownee Relationship的更多相关文章

  1. [React] React Fundamentals: Owner Ownee Relationship

    The owner-ownee relationship is used to designate a parent-child relationship with React components ...

  2. [React] React Fundamentals: Accessing Child Properties

    When you're building your React components, you'll probably want to access child properties of the m ...

  3. [React Fundamentals] Composable Components

    To make more composable React components, you can define common APIs for similar component types. im ...

  4. [React Fundamentals] Component Lifecycle - Updating

    The React component lifecycle will allow you to update your components at runtime. This lesson will ...

  5. [React Fundamentals] Component Lifecycle - Mounting Usage

    The previous lesson introduced the React component lifecycle mounting and unmounting. In this lesson ...

  6. [React Fundamentals] Component Lifecycle - Mounting Basics

    React components have a lifecycle, and you are able to access specific phases of that lifecycle. Thi ...

  7. [React Fundamentals] Using Refs to Access Components

    When you are using React components you need to be able to access specific references to individual ...

  8. [React Fundamentals] Accessing Child Properties

    When you're building your React components, you'll probably want to access child properties of the m ...

  9. [React Fundamentals] State Basics

    State is used for properties on a component that will change, versus static properties that are pass ...

随机推荐

  1. 函数buf_LRU_free_from_unzip_LRU_list

    /******************************************************************//** Try to free an uncompressed ...

  2. storm - 基础概念整理

    理论 Hadoop的出现虽然为大数据计算提供了一条捷径,但其仍然存在自身难以克服的缺点:实时性不足.Hadoop的一轮计算的启动需要较长时间,因此其满足不了对实时性有较高要求的场景. Storm由此应 ...

  3. [原]Unity3D深入浅出 - 摄像机组件(Camera)

    在Unity中创建一个Camera后,除了默认带一个Transform组件外,还会附带Flare Layer.GUI Layer.Audio Listener等4个组件,如下图. ClearFlags ...

  4. Entityframework常用命令

    Enable-Migrations 启用Migration数据迁移 Add-Migration migrationname 添加一个migration Update-Database –TargetM ...

  5. css padding在ie7、ie6、firefox中的兼容问题

    padding 简写属性在一个声明中设置所有内边距属性. 说明这个简写属性设置元素所有内边距的宽度,或者设置各边上内边距的宽度.行内非替换元素上设置的内边距不会影响行高计算:因此,如果一个元素既有内边 ...

  6. 【Java基础之容器】Iterator

    Iterator: ->所有实现了Collection接口的容器类都有一个iterator方法用以返回一个实现了Iterator接口的对象 ->Iterator对象称作迭代器,用以方便的实 ...

  7. C++ 学习资料搜寻与学习(第一期)(未完待续)

    一.图形图像类 [Visual C++]vs2008/2005正确打开vs2010所创建项目的几种方法 jlins 2012-04-12 14:38 [Visual C++]关于无法打开包括文件:“S ...

  8. 017QTP 描述性编程的使用方法

    一.什么时候使用描述性编程 在测试过程中,有些界面元素是动态出现或动态变化的,在录制的时候并没有添加到对象库中 二.描述性编程的运行原理 用描述性编程编写的测试脚本在运行时,QTP会使用测试脚本中给出 ...

  9. 【转】java list用法示例详解

    转自:http://www.jb51.net/article/45660.htm java中可变数组的原理就是不断的创建新的数组,将原数组加到新的数组中,下文对java list用法做了详解. Lis ...

  10. leetcode–Binary Tree Maximum Path Sum

    1.题目说明 Given a binary tree, find the maximum path sum.   The path may start and end at any node in t ...