Skip to content

Commit 10b0dc9

Browse files
committed
1st step: Link Square Components state with Board Component.
1 parent 864d798 commit 10b0dc9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ class Game extends React.Component {
1818

1919

2020
class Board extends React.Component {
21+
constructor(props) { // Add Square Components (children) behaviour to Board Component (parent)
22+
super(props);
23+
this.state = {
24+
squares: Array(9).fill(null), // 3x3 Array of no-state cells.
25+
};
26+
}
27+
2128
renderSquare(i) {
22-
return <Square value={i} />;
29+
return <Square value={this.state.squares[i]} />; // Board know Squares initial state so we can define it.
2330
}
2431

2532
render() {

0 commit comments

Comments
 (0)