This lesson will teach you the basics of setting properties in your React components.

class App extends React.Component {
render(){
let txt = this.props.txt
return <h1>{txt}</h1>
}
} App.propTypes = {
txt: React.PropTypes.string,
cat: React.PropTypes.number.isRequired
} App.defaultProps ={
txt: 'this is the default txt'
} ReactDOM.render(
<App cat={5} />,
document.getElementById('app')
);

[React Fundamentals] Introduction to Properties的更多相关文章

  1. [React Fundamentals] Accessing Child Properties

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

  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] State Basics

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

  4. [React] React Fundamentals: transferPropsTo

    the transferPropsTo method lets you easily push properties into your components to easily customize ...

  5. [React] React Fundamentals: State Basics

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

  6. [React Fundamentals] Composable Components

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

  7. [React Fundamentals] Component Lifecycle - Updating

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

  8. [React Fundamentals] Component Lifecycle - Mounting Usage

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

  9. [React Fundamentals] Component Lifecycle - Mounting Basics

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

随机推荐

  1. poj2229

    很不错的一道题,这里提供两种方法: 方法1:递推: 易知当n为奇数时,f[n]=f[n-1] (n-1的所有方案前面添1,并且没有新的方案): 重点是n为偶数的时候,则拆分方案中,要么有偶数个1,要么 ...

  2. 利用Merge Into 更新表,集合数据到数据库中

    使用Merge INTO 将表数据更新到数据库中 创建User-Defined Table Types   创建要更新的UserDetails表 创建更新存储过程 程序调用存储过程 查看结果

  3. [POJ 2461] Billiard

    同swustoj 11 Billiard Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1362   Accepted: 8 ...

  4. 建立自己的bin目录,在当前路径运行shell脚本

    Shell脚本nusers cat nusers #! /bin/sh - who | wc -l 如果你要编写自己的脚本,最好准备自己的bin目录来存放它们,并且让Shell能够自动找到它们.这不难 ...

  5. (转)INSTALLSHIELD 2010 预安装组件和软件

    使用Installshield2010提供的组件 大家再开发软件产品的时候经常是基于某些软件和类库的,像我们的项目就用到了.Net Framework3.5,mapinfo,sqlserver 200 ...

  6. u-boot 环境变量参数设置

    今天本来是烧写内核,结果一不小心把uboot也整不能用了,无奈之下只好重新烧个uboot,等都弄好以后,发现系统还是启动不了,原来是启动参数设置不对,于是找到了这篇文章,//是我添加的内容. 原文地址 ...

  7. MEX文件编写和调试

    作者kaien,2010/02/16 以前我写过一篇文章,详细的介绍过MEX的格式,语法,编译,调试等.可惜记不清放在哪里了.而最近又用到MEX编程,所以只能重新温习一番.时间有限,只记下简要流程和注 ...

  8. (Java)利用ListIterator(iterator 重复器/迭代器的子接口) 操作ArrayList

    add()方法是在下一个将要取得的元素之前插入新的元素.因此如果在下一个将要取得的元素的序号为0,则在序号0的元素前插入新的元素. 测试: 见第1.行,在序号为0的元素前添加一个元素. 见第2.行:这 ...

  9. Diamond

    Diamond主要提供持久配置的发布和订阅服务,最大特点是结构简单,稳定可靠.Diamond的主要使用场景是用来进行动态数据库切换与扩容,进行一些业务系统运行时开关配置的推送.Diamond产品专注于 ...

  10. 浅谈 Python 的 with 语句

    with 语句是在 Python 2.5 版本引入的,从 2.6 版本开始成为缺省的功能.with 语句作为 try/finally 编码范式的一种替代,用于对资源访问进行控制的场合.本章对 with ...