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.
 
 

36 lines
991 B

require('../../sass/board/grid.scss');
import { Component } from 'react';
import { connect } from 'react-redux';
import GridCell from './grid-cell.component';
import * as Actions from '../../actions/board/grid.actions';
import { SETTINGS } from '../../App';
export default class Grid extends Component {
componentDidMount(n) {
this.props.dispatch(Actions.generateValues(SETTINGS.GRID_WIDTH * SETTINGS.GRID_HEIGHT, 1));
};
render() {
const { values } = this.props;
const cells = [];
let i;
for (let x = 0; x < SETTINGS.GRID_WIDTH; x++) {
for (let y = 0; y < SETTINGS.GRID_HEIGHT; y++) {
i = y * SETTINGS.GRID_WIDTH + x;
cells.push(<GridCell value={values[i]} x={x} y={y} key={i} />);
}
}
return (<div className='grid'>{cells}</div>);
};
};
const select = (state) => {
return {
values: state.grid
}
};
export default connect(select)(Grid);