30 lines
651 B
JavaScript
30 lines
651 B
JavaScript
|
|
import React from 'react';
|
||
|
|
|
||
|
|
class GridField extends React.Component {
|
||
|
|
constructor(props) {
|
||
|
|
super(props);
|
||
|
|
|
||
|
|
this.state = {
|
||
|
|
currentObj: 'w',
|
||
|
|
obj: this.props.obj,
|
||
|
|
active: false
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
isActive() {
|
||
|
|
return 'field'
|
||
|
|
+ (this.state.active === true ? ' active' : '')
|
||
|
|
+ (this.state.active === true && this.state.obj === 'm' ? ' mine' : '');
|
||
|
|
}
|
||
|
|
|
||
|
|
render() {
|
||
|
|
return (
|
||
|
|
<div className={this.isActive()} onClick={this.props.onClick}>
|
||
|
|
{this.state.currentObj}
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export default GridField;
|