按老师的顺序及语法编写了js文件,运行结果如下!!
按老师的顺序及语法编写了js文件,运行结果如下!!
按老师的顺序及语法编写了js文件,运行结果如下!!
2018-07-16
/*** Sample React Native App* https://github.com/facebook/react-native* @flow*/import React, { Component } from 'react';import {Platform,StyleSheet,Text,View} from 'react-native';const instructions = Platform.select({ios: 'Press Cmd+R to reload,\n' +'Cmd+D or shake for dev menu',android: 'Double tap R on your keyboard to reload,\n' +'Shake or press menu button for dev menu',});// 新建一个类ES6export default class LifecycleComponent extends Component{constructor(props){super(props);console.log("------run------")this.state={count:0,}}componentWillMount(){console.log("------run componentWillMount------")}componentDidMount(){console.log("------run componentDidMount------")}componentWillReceiveProps(nextProps){console.log("------run componentWillReceiveProps------")}shouldComponentUpdate(nextProps,nextState){console.log("------run shouldComponentUpdate------")return true;}componentWillUpdate(nextProps,nextState){console.log("------run componentWillUpdate------")}componentDidUpdate(prevProps,prevState){console.log("------run componentDidUpdate------")}componentWillUnmount(){console.log("------run componentWillUnmoun------")}render(){console.log("run")return(<View><Text style={styles.text1}onPress={()=>{this.setState({count:this.state.count+1,})}}> hello.LifecycleComponent holle多少次{this.state.count}</Text></View>);}}const styles = StyleSheet.create({text1:{fontSize:20,backgroundColor:'#f5f',}});
举报