React 生命周期表

React lifecycle

Method Side effects1 State updates2 Example uses
<big>Mounting</big>
componentWillMount Constructor 相当于 createClass
render Create and return element(s)
componentDidMount DOM操作,网络请求等
<big>Updating</big>
componentWillReceiveProps Update state based on changed props
shouldComponentUpdate Compare inputs and determine if render needed
componentWillUpdate Set/reset things (eg cached values) before next render
render Create and return element(s)
componentDidUpdate DOM操作,网络请求等
<big>Unmounting</big>
componentWillUnmount DOM操作,网络请求等

查看完整资料 请点击这里

  1. "Side effects" 是指修改变量之外的实例,异步操作,等等。
  2. "State updates" 是指当前实例(如“this.setState”)。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容