React 生命周期表

2017-07-06  本文已影响0人  andreaxiang

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”)。
上一篇 下一篇

猜你喜欢

热点阅读