You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
900 B
41 lines
900 B
import { Component } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import * as creators from '../app/Creators.js';
|
|
|
|
let blinkTimer = null;
|
|
|
|
const toggleTimeout = function() {
|
|
var hidden = this.props.blink;
|
|
this.props.dispatch(creators.toggleBlink());
|
|
blinkTimer = setTimeout(toggleTimeout.bind(this), 600);
|
|
};
|
|
|
|
export default class NewGame extends Component {
|
|
componentDidMount() {
|
|
toggleTimeout.call(this);
|
|
};
|
|
|
|
componentWillUnmount() {
|
|
clearTimeout(blinkTimer);
|
|
};
|
|
|
|
render() {
|
|
const classname = ['newgame'];
|
|
|
|
if (this.props.blink === true) {
|
|
classname.push('hidden');
|
|
}
|
|
|
|
return (
|
|
<div className={classname.join(' ')}>Press Space Bar To Play</div>
|
|
);
|
|
};
|
|
};
|
|
|
|
const select = (state) => {
|
|
return {
|
|
blink: state.blink
|
|
}
|
|
};
|
|
|
|
export default connect(select)(NewGame);
|
|
|