'use strict';
import React,{Component} from 'react';
import {AppRegistry,View,Text} from 'react-native';
class Playground extends Component {
// 构造
constructor(props) {
super(props);
// 初始状态
console.log('constructor');
}
render() {
return (
<View accessible={true}>
<Text>text one</Text>
<Text>text two</Text>
</View>
);
}
componentDidMount() {
this.timer = setTimeout(
() => { console.log('把一个定时器的引用挂在this上'); },
500
);
}
componentDidUnMount() {
this.timer && clearTimeout(this.timer);
}
}
//MyFirstProject
AppRegistry.registerComponent('MyFirstProject', () => Playground);
React-native之定时器
最新推荐文章于 2024-06-16 09:43:29 发布