美文网首页
React 生命周期表

React 生命周期表

作者: andreaxiang | 来源:发表于2017-07-06 22:40 被阅读0次

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”)。

相关文章

网友评论

      本文标题:React 生命周期表

      本文链接:https://www.haomeiwen.com/subject/famkhxtx.html