import React, { Component } from ‘react’;
import { AppRegistry, Text, View } from ‘react-native’;
class Blink extends Component {
//构造函数
constructor(props) {
super(props);
this.state = { showText: true };
// 定时器毫秒
setInterval(() => {
this.setState({ showText: !this.state.showText });
}, 1000);
}
render() {
// 根据当前showText的值决定是否显示text内容
let display = this.state.showText ? this.props.text : ’ ‘;
return (
{display}
);
}
}
class Test5 extends Component {
render() {
return (
);
}
}
AppRegistry.registerComponent(‘BlinkApp’, () => Test5);