对React生命周期的理解

React 16.3之前 1、getDefaultProps() 设置默认的props,也可以用dufaultProps设置组件的默认属性. 2、getInitialState() 在使用es6的class语法时是没有这个钩子函数的,可以直接在constructor中定义this.state。此时可以访问this.props 3、componentWillMount() 组件初始化时只调用,以后组
相关文章
相关标签/搜索