react-native生命周期
2017-10-07 16:15
417 查看
//初始化 constructor(props) { super(props); console.log('---------constructor--------') } //组件将要加载,整个生命周期只执行一次,在render方法之前执行 componentWillMount() { console.log('---------componentWillMount--------') } //组件已经加载,在render方法之后执行,整个生命周期只执行一次 componentDidMount() { console.log('---------componentDidMount--------') } //在组件接收到其父组件传递的props的时候执行,参数为父组件传递的props。在组件的整个生命周期可以多次执行 componentWillReceiveProps(nextProps) { console.log('---------componentWillReceiveProps--------') this.setState({ //key : value }); } //在componentWillReceiveProps(nextProps)执行之后立刻执行;或者在state更改之后立刻执行 shouldComponentUpdate(nextProps, nextState) { console.log('---------shouldComponentUpdate--------') return true; } //在shouldComponentUpdate(nextProps, nextState)函数执行完毕之后立刻调用,该方法包含两个参数 componentWillUpdate(nextProps, nextState) { console.log('---------componentWillUpdate--------') } //在render()方法执行之后立刻调用。该方法包含两个参数,分别是props和state componentDidUpdate(preProps, preState) { console.log('---------componentDidUpdate--------') } //render方法用于渲染组件。在初始化阶段和运行期阶段都会执行。 render() { console.log('---------render--------') return ( <Tex></Text> ); } //在组件由虚拟DOM卸载的时候调用 componentWillUnmount() { console.log('---------componentWillUnmount--------') }
相关文章推荐
- React Native之生命周期
- React Native 中 component 生命周期
- Android React Native组件的生命周期
- react-native 的生命周期,以及通信关系,转载
- ReactNative Component 生命周期
- React-Native 之 生命周期
- React-Native 组件 生命周期
- React Native 中组件的生命周期
- React-Native 中的生命周期
- react-native 组件的生命周期
- React Native入门——组件构成及生命周期简介
- React Native 中组件的生命周期
- react-native组件的生命周期
- [ReactNative] 03--ReactNative的生命周期 & render的Diff算法 & 组件之间的通信
- React Native生命周期
- React Native 中组件的生命周期
- React-Native 初学之组件生命周期记录
- RN(react native)入坑指南-10,组件的生命周期
- React-Native学习笔记之生命周期
- React Native 中组件的生命周期