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