React生命周期大总结
- getDefaultProps,通过这个方法初始化props属性,props来自于父组件,以及其他组件
- getInitialState,初始化当前组件的状态,这个状态会贯穿整个项目,数据变化都取决于setState
- componentWillMount,在组件加载和初始化之前调用
- render ,react中最重要的方法,react元素的渲染都取决于render
- componentDidMount,react DOM加载完会调用这个方法
- componentWillReceiveProps,来自父组件属性的传递调用的方法
- shouldComponentUpdate,组件的更新,只要调用setState就会调用这个生命周期钩子
- componentWillUpdate,组件更新之前调用的方法
- componentDidUpdate ,组件更新之后调用的方法
- componentWillUnmount,组件销毁调用的方法