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. SSMS错误代码大全

    0 操作成功完成. 1 功能错误. 2 系统找不到指定的文件. 3 系统找不到指定的路径. 4 系统无法打开文件. 5 拒绝访问. 6 句柄无效. 7 存储控制块被损坏. 8 存储空间不足,无法处理此 ...

  2. guake默认快捷键

    toggle guake visibility   切换guake可见 :F12 toggle fullscreen   切换全屏幕 :F11 quit   退出 :Shift+Ctrl+Q new ...

  3. hbase分页查询

    为了广大技术爱好者学习netty,在这里帮新浪微博@nettying宣传下他出版的新书 <netty权威指南>@nettying兄在华为NIO实践多年,这本书是他的技术和经验的一个结晶.N ...

  4. Codeforces 628D 数位dp

    题意:d magic number(0<=d<9)的意思就是一个数,从最高位开始奇数位不是d,偶数位是d 题目问,给a,b,m,d(a<=b,m<2000)问,a,b之间有多少 ...

  5. 设计模式_Visitor_访问者模式

    形象例子: 情人节到了,要给每个MM送一束鲜花和一张卡片,可是每个MM送的花都要针 对她个人的特点,每张卡片也要根据个人的特点来挑,我一个人哪搞得清楚,还是找花店老板和礼品店老板做一下Visitor, ...

  6. 【转】C/C++除法实现方式及负数取模详解

    原帖:http://blog.csdn.net/sonydvd123/article/details/8245057 一.下面的题目你能全做对吗? 1.7/4=? 2.7/(-4)=? 3.7%4=? ...

  7. 2016"百度之星" - 初赛(Astar Round2B) 1006 中位数计数

    思路:统计当前数左边比它小|大 i个人,相应右边就应该是比它大|小i个人 l数组表示左边i个人的方案 r表示右边i个人的方案 数组下标不可能是负数所以要加n //#pragma comment(lin ...

  8. hdoj 2032 杨辉三角

    杨辉三角 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  9. APUE读书笔记-第17章-高级进程间通信

    17.1 引言 *两种高级IPC:基于STREAMS的管道(STREAMS-based pipe)以及UNIX域套接字(UNIX domain socket)可以在进程间传送打开文件描述符.服务进程可 ...

  10. 325. Maximum Size Subarray Sum Equals k

    最后更新 二刷 木有头绪啊.. 看答案明白了. 用的是two sum的思路. 比如最终找到一个区间,[i,j]满足sum = k,这个去见可以看做是 [0,j]的sum 减去 [0,i]的Sum. 维 ...