type Color = "Blue" | "Red" | null
type Connect4Cell = {
state: number,
color: Color
}
type State = {
gameBoard?: Array<Array<Connect4Cell>>
}
class Game extends React.Component<{||}, State> {
state = {
gameBoard: [
[{}, {}, {}, {}, {}],
[{}, {}, {}, {}, {}],
[{}, {}, {}, {}, {}],
[{state: 1, color: "Blue"}, {state: 1, color: "Red"}, {state: 1, color: "Blue"}, {state: 1, color: "Red"}, {state: 0, color: null}]
]
}
render() {
let board = this.state.gameBoard.map<React.Element<any>>(row => <Row />)
console.log(this.state)
return (
<div>
<p>This line comes from the render of class, Game. </p>
<table>
<tbody>
{board}
</tbody>
</table>
<Cell />
<Row />
</div>
)
}
}
I can't find out why its giving me this error?
Exact Error Message (on .map):
Cannot call
this.state.gameBoard.mapbecause propertymapis missing in undefined [1].Flow(InferError)
this.state.gameBoard.map<React.Element<any>>(row => <Row />)should be simplythis.state.gameBoard.map(row => <Row />)- frontendgirl