博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[React] React Fundamentals: Component Lifecycle - Mounting Basics
阅读量:6991 次
发布时间:2019-06-27

本文共 1151 字,大约阅读时间需要 3 分钟。

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.

 

Mounting: componentWillMount

Invoked once, both on the client and server, immediately before the initial rendering occurs. If you call setState within this method, render() will see the updated state and will be executed only once despite the state change.

 

Mounting: componentDidMount

Invoked once, only on the client (not on the server), immediately after the initial rendering occurs. At this point in the lifecycle, the component has a DOM representation which you can access via React.findDOMNode(this).

If you want to integrate with other JavaScript frameworks, set timers using setTimeout orsetInterval, or send AJAX requests, perform those operations in this method.

 

Unmounting: componentWillUnmount

Invoked immediately before a component is unmounted from the DOM.

Perform any necessary cleanup in this method, such as invalidating timers or cleaning up any DOM elements that were created in componentDidMount.

 

    
React Lesson 9: Mounting

 

转载地址:http://vkbvl.baihongyu.com/

你可能感兴趣的文章
stl学习之模板
查看>>
CentOS-7.3.1611编译安装 Nginx-1.12.1+mysql-5.7.19+PHP-7.1.8+zabbix-3.4.1
查看>>
元学习 - Learning How to Learn - 第一课:集中与发散思维
查看>>
一种具有细节保留功能的磨皮算法。
查看>>
排序算法7--选择排序--堆排序
查看>>
iOS开发规范&建议
查看>>
[原]如何为SqlServer2008数据库分配用户
查看>>
【leetcode】Basic Calculator III
查看>>
关于CCS中一些错误的解决方法
查看>>
回归到jquery
查看>>
安卓截屏如何实现将摄像头显示画面截下来
查看>>
jquery常识
查看>>
EF中的MySql返回 DataTable公共类库
查看>>
Visual Studio 2008常见问题
查看>>
【洛谷 P4254】 [JSOI2008]Blue Mary开公司(李超线段树)
查看>>
scrapy初体验 - 安装遇到的坑及第一个范例
查看>>
OC内存管理
查看>>
C#中Split用法
查看>>
3月6日 c#语言
查看>>
[LeetCode] Surrounded Regions, Solution
查看>>