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. poj 1062 昂贵的聘礼(最短路 dijk+枚举)

    终于A 了,这题做着真麻烦 题目:http://poj.org/problem?id=1062 dijk 一般用于正权有向图 此题的关键在于等级限制的处理,最好的办法是采用枚举,即假设酋长等级为5,等 ...

  2. String的intern方法的用处

    今天第一次翻看Effective java,在其第一个item中讲静态工厂方法的有点的时候说到“它们每次被调用 的时候,不要非得创建一个新的对象”并在结尾处提到---"String.inte ...

  3. UPC 2224 Boring Counting ★(山东省第四届ACM程序设计竞赛 tag:线段树)

    [题意]给定一个长度为N的数列,M个询问区间[L,R]内大于等于A小于等于B的数的个数. [题目链接]http://acm.upc.edu.cn/problem.php?id=2224 省赛的时候脑抽 ...

  4. toastr

    $(function(){     //参数设置,若用默认值可以省略以下面代     toastr.options = {         "closeButton": false ...

  5. HTML DOM 教程Part1

    2015-05-08 摘自W3C School HTML DOM HTML DOM 定义了访问和操作HTML文档的标准方法.HTML DOM 把 HTML 文档呈现为带有元素.属性和文本的树结构(节点 ...

  6. [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.5

    Show that the inner product $$\bex \sef{x_1\vee \cdots \vee x_k,y_1\vee \cdots\vee y_k} \eex$$ is eq ...

  7. HDU 3271-SNIBB(数位dp)

    题意:给一个数q, q=1时求给定区间,给定进制,各数位和等于m的数字的个数 q=2时求给定区间,给定进制,各数位和等于m的数字中的第k大的数字 分析:dp[i][sum][j],表示长度为i当前数位 ...

  8. javascript-实现日期大写

    <script language="javascript"> $(document).ready(function() { //定义中文数组 var chinese = ...

  9. 第一章:绪论-Python开发工具的安装

    书中提到了操作系统平台尽量选 *nix.我这里选用的是 ubuntu 14.04 , 下面的操作均以此操作系统为例说明. 操作系统安装教程可以去网站上找,推荐用虚拟机的方式,Windows下可用的虚拟 ...

  10. Cppcheck代码分析(1)

    一.检查点 1.自动变量检查: 返回自动变量(局部变量)指针 2.越界检查: 数组越界返回自动变量(局部变量)指针 3.类检查: 构造函数初始化 4.内存泄露检查: 5.空指针检查: 6.废弃函数检查 ...