urbit/apps/timer/tile/components/flashing.js

27 lines
622 B
JavaScript
Raw Normal View History

2019-05-29 02:19:07 +03:00
import React, { Component } from 'react';
export default class Flashing extends Component {
constructor(props) {
super(props);
this.alive = true;
this.state = { color: "black" };
}
//memory cleanup
componentWillUnmount() {
this.alive = false;
}
render() {
setTimeout(()=>{
if(this.alive) {
if(this.state.color == "black") { this.setState({color: "white"}) }
else if(this.state.color == "white") { this.setState({color: "black"}) }
}
},400);
return <div style={{ color: this.state.color }}>
{this.props.children}
</div>
}
}