File tree 2 files changed +25
-10
lines changed
2 files changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -7,15 +7,24 @@ export default class App extends React.Component {
7
7
playing : true ,
8
8
}
9
9
10
+ updatePlay = ( ) => {
11
+ this . setState ( ( prevState ) => {
12
+ console . log ( "UpdatePlay reached" ) ;
13
+ return {
14
+ playing : ! prevState . playing
15
+ }
16
+ } )
17
+ }
18
+
10
19
render ( ) {
11
-
12
- return (
13
- < React . Fragment >
14
- < Title />
15
- < Game />
16
- </ React . Fragment >
17
- )
20
+
21
+ return (
22
+ < React . Fragment >
23
+ < Title />
24
+ < Game updatePlay = { this . updatePlay } />
25
+ </ React . Fragment >
26
+ )
27
+ }
18
28
}
19
- }
20
29
21
30
Original file line number Diff line number Diff line change @@ -40,9 +40,15 @@ export default class Game extends React.Component {
40
40
return {
41
41
chances : prevState . chances - 1 ,
42
42
}
43
- } )
43
+ } , this . checkChances )
44
+ }
45
+ }
46
+
47
+ checkChances = ( ) => {
48
+ const chances = this . state . chances ;
49
+ if ( chances == 0 ) {
50
+ this . props . updatePlay ( ) ;
44
51
}
45
-
46
52
}
47
53
48
54
render ( ) {
You can’t perform that action at this time.
0 commit comments