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.
 
 

35 lines
900 B

require('../../sass/board/grid.scss');
import { Component } from 'react';
import { connect } from 'react-redux';
import GridCell from './grid-cell.component';
import GridActions from '../../actions/board/grid.actions';
import { SETTINGS } from '../../App';
export class Grid extends Component {
componentDidMount() {
this.props.dispatch(GridActions.update());
};
render() {
const { values } = this.props.values;
const cells = [];
this.props.values.map((v, i) => {
const x = i % SETTINGS.GRID_WIDTH;
const y = Math.floor(i / SETTINGS.GRID_WIDTH);
cells.push(<GridCell value={v.value} show={v.show} x={x} y={y} key={i} />);
});
return (<div className='grid'>{cells}</div>);
};
};
const select = (state) => {
return {
values: state.grid
}
}
export default connect(select)(Grid);