import React, { Component } from ‘react’;
import {
AppRegistry,
StyleSheet,
Text,
View
} from ‘react-native’;
export default class xxs extends Component {
//1.创建阶段
getDefaultProps() {
// 在创建类的时候被调用
console.log(“getDefaultProps–>getDefaultProps”);
}
// 构造
constructor(props) {
super(props);
//获取this.state的默认值
console.log("constructor-->constructor");
}
componentWillMount() {
//在render之前调用此方法
//在业务逻辑的处理都应该放在这里,如对state的操作等
console.log("componentWillMount-->"+"componentWillMount");
}
componentDidMount() {
// 该方法发生在render方法之后,在该方法中,ReactJs会使用render方法返回的虚拟Dom对象来创建真实的Dom结构
console.log("componentDidMount->componentDidMount");
}
//3.更新阶段
componentWillRecieveProps() {
//该方法发生在this.props被修改或父组件调用setProps()方法之后
console.log("componentWillRecieveProps->componentWillRecieveProps");
}
shouldComponentUpdate() {
//是否需要更新
console.log("shouldComponentUpdate->shouldComponentUpdate");
return true;
}
componentWillUpdate() {
//将要更新
console.log("componentWillUpdate->componentWillUpdate");
}
componentDidUpdate() {
//更新完毕
console.log("componentDidUpdate->componentDidUpdate");
}
//4.销毁阶段
componentWillUnmount() {
//销毁时被调用
console.log("componentWillUnmount->componentWillUnmount");
}
render() {
console.log('render');
return (
<View>
<Text>
Welcome to React Native!
</Text>
</View>
);
}
}
AppRegistry.registerComponent(‘TestFinancing’, () => xxs);