Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.state = {
- board: [
- [null, null, null, null],
- [null, null, null, null],
- [null, null, null, null],
- [null, null, null, null]
- ]
- }
- // x & y are the coordinates of the 2d array
- this.setState({
- board: update(this.state.board, {
- [x]: {
- [y]: { $set: { id, player, x, y, waitingToBeSelected } }
- }
- })
- });
- this.state = {
- board: [
- [null, null, null, null],
- [null, {id: 21, player: "p1", waitingToBeSelected: false, x:1, y:1}, null, null],
- [null, {id: 42, player: "p1", waitingToBeSelected: false, x:2, y:1}, null, null],
- [null, null, null, null]
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement