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. Linux sysfs device_attribute

    /*************************************************************************** * Linux sysfs device_at ...

  2. windows 7环境下配置oracle 11g 客户端

    首先要去官网上下载oracle 11客户端,(我用的是64位系统)地址: http://www.oracle.com/technetwork/database/features/instant-cli ...

  3. myeclipse2015不能启动tomcat,提示: Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at local

    myeclipse2015不能启动tomcat,提示: Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at local ...

  4. umask设置导致程序权限不足的问题

    这几天邮件告警总是发不了邮件,查看了下zext_msmtp.sh的日志,发现总是提示权限不足…… 于是切换为zabbix的账户,发现在msmtp的目录下连ls都无法执行. 之后发现是umask的问题, ...

  5. [LeetCode]切割字符串,使各个子串都是回文

    题目:Given a string s, partition s such that every substring of the partition is a palindrome. Return ...

  6. HIbernate学习笔记(六) 关系映射之多对多

    六.多对多 - 单向 Ø        一般的设计中,多对多关联映射,需要一个中间表 Ø        Hibernate会自动生成中间表 Ø        Hibernate使用many-to-ma ...

  7. HW5.33

    import java.util.Calendar; public class Solution { public static void main(String[] args) { long tot ...

  8. jexus asp.net Linux Web Server

    Jexus简介 Jexus web server for linux 是运行在Linux上的Web服务器.其安装和部署及其简单,直接支持Asp.net . 下载Jexus wget http://li ...

  9. Excel里的单元格提行

    最近老板发了个表,遇到了个小知识点,收藏以后有用!拿来学学 如下,是属于单元格.怎么提行? 直接,空格或space,都无法解决!...... 解决办法:Alt + Enter 成功! 参考: http ...

  10. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(无图)

    注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYinYinQi ...