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. OK335xS LAN8710 phy driver hacking

    /******************************************************************** * OK335xS LAN8710 phy driver h ...

  2. 【众秒之门 JavaScript与jQuery技术精粹 #BOOK#】第4章 数据类型及定义

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...

  3. ☀Chrome模拟移动端浏览器

  4. jQuery.Validate验证库

    一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...

  5. Eclipse文件编码设置的问题

    Eclipse中设置编码的方式 如果要使插件开发应用能有更好的国际化支持,能够最大程度的支持中文输出, 则最好使 Java文件使用UTF-8编码.然而,Eclipse工作空间(workspace)的缺 ...

  6. 4、什么构成了我们Android应用程序?(七大件)

    一.应用程序四大组件 [Activity] Activity是Android应用程序的一个界面,可以通过这个界面查看联系人,打电话戒玩游戏. b. 一个应用程序通常包含多个Activity. c. A ...

  7. 【Python】linux安装tornado

    想写个页面,又不想用tomcat,同事说可以用tornado,试一下 1 我从网上找了个hello world类似的程序,复制粘贴运行,提示 ImportError: No module named  ...

  8. lightoj 1018 (状态压缩DP)

    设dp[s]表示状态s下所需要的线段的个数,s的二进制中第x位为1就表示该状态下第x个点没被线段覆盖.需要预处理出来在任意两点之间连线所覆盖点的状态O(n^3),然后记忆化搜索即可. #include ...

  9. Microsoft Azure自动化测试

    在使用与微软Azure进行交互的工具并试图衡量性能时,基本上不可能得到任何类似于公平.一致的测试.在午餐时间执行的测试运行会得的一套计时与晚上每个人都离开办公室执行的测试所到的结果可能完全不同.结果取 ...

  10. Android编译过程详解(一)

    Android编译过程详解(一) 注:本文转载自Android编译过程详解(一):http://www.cnblogs.com/mr-raptor/archive/2012/06/07/2540359 ...