@@ -21,17 +21,10 @@ class Board extends Component<{}, BoardState> {
21
21
scoreboard : { X : 0 , O : 0 } ,
22
22
} ;
23
23
24
- // these methods need to be bound to the context of `this` since
25
- // these will be passed into event handlers and called from outside the object
26
- // where the context of `this` would be otherwise different
27
24
this . resetBoard = this . resetBoard . bind ( this ) ;
28
25
this . handleBoxClick = this . handleBoxClick . bind ( this ) ;
29
26
}
30
27
31
- componentDidMount ( ) {
32
- this . getScores ( ) ;
33
- }
34
-
35
28
componentDidUpdate ( ) {
36
29
this . checkForWinner ( ) ;
37
30
}
@@ -70,7 +63,6 @@ class Board extends Component<{}, BoardState> {
70
63
checkForWinner ( ) : void {
71
64
const { board, gameOver, currentPlayer } = this . state ;
72
65
73
- // helper function to check if board is filled
74
66
const spacesLeft = ( ) : boolean => {
75
67
for ( let i of board ) {
76
68
if ( i . includes ( '-' ) ) return true ;
@@ -114,8 +106,6 @@ class Board extends Component<{}, BoardState> {
114
106
message : `Player ${ winner } wins!` ,
115
107
} ) ;
116
108
117
- this . getScores ( 'POST' , JSON . stringify ( { winner } ) ) ;
118
-
119
109
// draw condition: no '-' remaining in board without above win condition triggering
120
110
} else if ( ! spacesLeft ( ) ) {
121
111
this . setState ( {
@@ -126,11 +116,6 @@ class Board extends Component<{}, BoardState> {
126
116
}
127
117
}
128
118
129
- getScores ( method ?: string , winner ?: string ) {
130
- // If method is GET, send a GET request to api route to get scores.
131
- // If method is POST, send a POST request to api route to post the scores.
132
- }
133
-
134
119
handleBoxClick ( row : number , column : number ) : void {
135
120
const boardCopy : BoardContent = [
136
121
[ ...this . state . board [ 0 ] ] ,
@@ -143,7 +128,6 @@ class Board extends Component<{}, BoardState> {
143
128
}
144
129
145
130
render ( ) {
146
- // insert logic to render rows here
147
131
const rows : Array < JSX . Element > = [ ] ;
148
132
for ( let i = 0 ; i < 3 ; i ++ ) {
149
133
rows . push (
@@ -155,7 +139,6 @@ class Board extends Component<{}, BoardState> {
155
139
/>
156
140
) ;
157
141
}
158
- // Destructure scores for X and O from state so that they can individually be rendered below
159
142
const { X, O } : Scoreboard = this . state . scoreboard ;
160
143
161
144
return (
0 commit comments