Private
Public Access
1
0

bugfix grid field render #12

This commit is contained in:
2016-11-18 20:03:54 +01:00
parent 165889346e
commit 541e2e605c
3 changed files with 21 additions and 11 deletions

View File

@@ -16,6 +16,8 @@ class GridControl extends React.Component {
env: props.env,
webPlayer: null,
grid: null,
renderGridFields: false,
gridFields: [],
updatedFieldCache: [],
bombFieldCache: [],
foundUserMineCache: 0,
@@ -382,13 +384,11 @@ class GridControl extends React.Component {
return 'game-overlay' + ( this.state.overlay ? '' : ' hide' );
}
render() {
var grid = [];
renderGridFields() {
if (this.state.grid) {
for (let i = 0, j = this.state.grid.length; i < j; i++) {
for (let k = 0, l = this.state.grid[i].length; k < l; k++) {
grid.push(
this.state.gridFields.push(
<GridField row={i}
col={k}
ref={this.refString(i, k)}
@@ -399,6 +399,12 @@ class GridControl extends React.Component {
}
}
}
}
render() {
/** Render the grid fields just one time in one party #12 */
this.state.renderGridFields && this.renderGridFields();
this.state.renderGridFields = false;
return (
<div className="game-wrapper">
@@ -411,7 +417,7 @@ class GridControl extends React.Component {
<UserControl ref="userControl"
bombClear={this.bombClear.bind(this)}/>
<div className="grid-container">
<div className="grid"> {grid} </div>
<div className="grid"> {this.state.gridFields} </div>
</div>
</div>
);