react-native生命周期
来源:互联网 发布:ubuntu16.04启动mysql 编辑:程序博客网 时间:2024/06/03 16:43
//初始化 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--------') }
阅读全文
0 0
- React Native 组件生命周期
- React Native生命周期整理
- React Native生命周期
- React-Native 生命周期
- react-native--生命周期
- react native 组件生命周期
- React Native 生命周期
- React Native 之生命周期
- React Native之生命周期
- react native Component 生命周期
- React Native组件生命周期
- React-Native 中的生命周期
- React Native组件生命周期
- React-Native生命周期详解
- react-native 组件生命周期
- React-Native 组件 生命周期
- react-native 生命周期
- React Native 生命周期
- 头文件模板
- mac安装brew经验
- hibernate 用注解方式生成uuid方法
- 重磅教程!帮你全面彻底搞定Material design的学习笔记
- 八皇后问题用C语言解决
- react-native生命周期
- Selenium 库学习笔记
- 【Linux】Linux发布项目
- 10.7NOIP模拟赛
- Hdu 4433 locker【思维+Dp】
- HttpCore 第一章 基础知识
- [POI2008]BLO-Blockade
- Python补充05 字符串格式化 (%操作符)
- - 敌兵布阵 HDU