文章标题

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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值