React components have a lifecycle, and you are able to access specific phases of that lifecycle. This lesson will introduce mounting and unmounting of your React components.

import React from 'react';
import ReactDOM from 'react-dom'; export default class App extends React.Component {
constructor(){
super();
this.state = {
val:
}
}
update(){
this.setState({
val: this.state.val +
})
}
componentWillMount(){
console.log("Component Will Mount");
}
render() {
console.log("rendering");
return (
<div>
<button onClick={this.update.bind(this)}>{this.state.val}</button>
</div>
)
}
componentDidMount(){
console.log("Component Did Mount");
}
}

"componentWillMount" happen before rendering, "state" and "props" are ready, but DOM is not rendered yet.

"componentDidMount" happen after component rendered to the DOM, can access DOM Node.

[React Fundamentals] Component Lifecycle - Mounting Basics的更多相关文章

  1. [React] React Fundamentals: Component Lifecycle - Mounting Basics

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

  2. [React Fundamentals] Component Lifecycle - Mounting Usage

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

  3. [React ] React Fundamentals: Component Lifecycle - Mounting Usage

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

  4. [React Fundamentals] Component Lifecycle - Updating

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

  5. [React] React Fundamentals: Component Lifecycle - Updating

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

  6. React.js Tutorial: React Component Lifecycle

    Introduction about React component lifecycle. 1 Lifecycle A React component in browser can be any of ...

  7. React (Native) Rendering Lifecycle

    How Does React Native Work? The idea of writing mobile applications in JavaScript feels a little odd ...

  8. React & styled component

    React & styled component https://www.styled-components.com/#your-first-styled-component tagged t ...

  9. react slot component with args

    react slot component with args how to pass args to react props child component https://codesandbox.i ...

随机推荐

  1. 基于Struts2的用户登录程序

    基本步骤: 1.新建Java工程,File>New>Project>Web>Dynamic Web Project,并将工程命名为:Struts2_Demo 2.导入strut ...

  2. 利用icepdf将pdf文件转为图片

    所需jar 包为icepdf-core.jar.icepdf-extra.jar.icepdf-pro-intl.jar.icepdf-pro.jar和icepdf-viewer.jar. 示例代码如 ...

  3. EF框架step by step(8)—Code First DataAnnotations(2)

    上一篇EF框架step by step(7)—Code First DataAnnotations(1)描述了实体内部的采用数据特性描述与表的关系.这一篇将用DataAnnotations描述一下实体 ...

  4. Android学习过程

    0. Tutorial 1. 基础知识的书 2. 实践为主的书 3. 阅读开源项目 4. 自己做项目 5. 理论为主的书 6. 编程规范和技巧性的书 通过实例了解Android开发 组件:Activi ...

  5. [Tommas] 测试场景 VS 测试用例 哪个更好?(转)

    分享一篇网上别人的感悟:      6年前,我在一家中型跨国公司工作的时候,我建议与其浪费时间在准备充分的测试用例,还不如编写描述测试场景的文档.所有的人都对我的建议.投以烦恼的目光.他们的脸上清晰地 ...

  6. LR 常见问题总结

    问题1:Error: Two Way Communication Error:            Function two_way_comm_post_message/two_way_comm_p ...

  7. JSON 格式的转换: 数组、字符串、List集合、DataTable,实体对象

    JSON验证工具:http://jsonlint.com/JSON简明教程:http://www.w3school.com.cn/json/Newtonsoft.Json类库下载:http://jso ...

  8. [GRYZ2015]阿Q的停车场

    题目描述 刚拿到驾照的KJ 总喜欢开着车到处兜风,玩完了再把车停到阿Q的停车场里,虽然她对自己停车的水平很有信心,但她还是不放心其他人的停车水平,尤其是Kelukin.于是,她每次都把自己的爱车停在距 ...

  9. 《C Primer Plus 第五版》读书笔记

    CH1-2:概述 链接器:链接库代码.启动代码(start-up code) CH3-5:数据.字符串.运算符 1 数据类型存储方式:整数类型.浮点数类型 2 浮点数存储:小数部分+指数部分 3 in ...

  10. class0513(html基础加强)

    内容:HTML.CSS 目标:掌握手写HTML实现一般难度的Web页面的能力(如网站注册表单),为ASP.Net学习打基础.坚持手写HTML,可视化设计只是一种自学的手段. 参考书:张孝祥<Ja ...