您的位置:首页 > Web前端 > React

react-native 生命周期

2017-10-26 17:24 323 查看

react-native 生命周期

1.创建阶段

1.getDefaultProps() 处理外部传进来的属性,建议使用

static defaultProps = {
title: '',  // 标题
};


2.实例化阶段

1.render() 启动之后,渲染布局

2.getInitialState() 初始化组件的state值,建议使用

constructor(props) {
super(props);

// 设置state的值
this.state = {
isOn: false,
};
}


3.componentWillMount() 在render之前调用此方法,如处理state的操作

4.componentDidMount() 在render之后调用

5.componentWillUnmount()组件将要被卸载

componentWillUnmount() {
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  react-native