File tree Expand file tree Collapse file tree 6 files changed +46
-91
lines changed Expand file tree Collapse file tree 6 files changed +46
-91
lines changed Original file line number Diff line number Diff line change @@ -17,26 +17,19 @@ function Instructions() {
17
17
}
18
18
19
19
class PlayerInput extends React . Component {
20
- constructor ( props ) {
21
- super ( props ) ;
22
-
23
- this . state = {
24
- username : "" ,
25
- } ;
26
-
27
- this . handleSubmit = this . handleSubmit . bind ( this ) ;
28
- this . handleChange = this . handleChange . bind ( this ) ;
29
- }
30
- handleSubmit ( event ) {
20
+ state = {
21
+ username : "" ,
22
+ } ;
23
+ handleSubmit = ( event ) => {
31
24
event . preventDefault ( ) ;
32
25
33
26
this . props . onSubmit ( this . state . username ) ;
34
- }
35
- handleChange ( event ) {
27
+ } ;
28
+ handleChange = ( event ) => {
36
29
this . setState ( {
37
30
username : event . target . value ,
38
31
} ) ;
39
- }
32
+ } ;
40
33
render ( ) {
41
34
return (
42
35
< form className = "card" onSubmit = { this . handleSubmit } >
@@ -97,27 +90,20 @@ PlayerPreview.propTypes = {
97
90
} ;
98
91
99
92
export default class Battle extends React . Component {
100
- constructor ( props ) {
101
- super ( props ) ;
102
-
103
- this . state = {
104
- playerOne : null ,
105
- playerTwo : null ,
106
- } ;
107
-
108
- this . handleSubmit = this . handleSubmit . bind ( this ) ;
109
- this . handleReset = this . handleReset . bind ( this ) ;
110
- }
111
- handleSubmit ( id , player ) {
93
+ state = {
94
+ playerOne : null ,
95
+ playerTwo : null ,
96
+ } ;
97
+ handleSubmit = ( id , player ) => {
112
98
this . setState ( {
113
99
[ id ] : player ,
114
100
} ) ;
115
- }
116
- handleReset ( id ) {
101
+ } ;
102
+ handleReset = ( id ) => {
117
103
this . setState ( {
118
104
[ id ] : null ,
119
105
} ) ;
120
- }
106
+ } ;
121
107
render ( ) {
122
108
const { playerOne, playerTwo } = this . state ;
123
109
const disabled = ! playerOne || ! playerTwo ;
Original file line number Diff line number Diff line change 1
1
import * as React from "react" ;
2
2
3
3
export default class Hover extends React . Component {
4
- constructor ( props ) {
5
- super ( props ) ;
6
-
7
- this . state = {
8
- hovering : false ,
9
- } ;
10
-
11
- this . mouseOver = this . mouseOver . bind ( this ) ;
12
- this . mouseOut = this . mouseOut . bind ( this ) ;
13
- }
14
- mouseOver ( ) {
4
+ state = {
5
+ hovering : false ,
6
+ } ;
7
+ mouseOver = ( ) => {
15
8
this . setState ( { hovering : true } ) ;
16
- }
17
- mouseOut ( ) {
9
+ } ;
10
+ mouseOut = ( ) => {
18
11
this . setState ( { hovering : false } ) ;
19
- }
12
+ } ;
20
13
render ( ) {
21
14
return (
22
15
< div onMouseOver = { this . mouseOver } onMouseOut = { this . mouseOut } >
Original file line number Diff line number Diff line change @@ -11,13 +11,9 @@ const styles = {
11
11
} ;
12
12
13
13
class Delayed extends React . Component {
14
- constructor ( props ) {
15
- super ( props ) ;
16
-
17
- this . state = {
18
- show : false ,
19
- } ;
20
- }
14
+ state = {
15
+ show : false ,
16
+ } ;
21
17
componentDidMount ( ) {
22
18
this . timeout = window . setTimeout ( ( ) => {
23
19
this . setState ( { show : true } ) ;
@@ -41,13 +37,9 @@ Delayed.propTypes = {
41
37
} ;
42
38
43
39
export default class Loading extends React . Component {
44
- constructor ( props ) {
45
- super ( props ) ;
46
-
47
- this . state = {
48
- content : props . text ,
49
- } ;
50
- }
40
+ state = {
41
+ content : this . props . text ,
42
+ } ;
51
43
componentDidMount ( ) {
52
44
const { speed, text } = this . props ;
53
45
Original file line number Diff line number Diff line change @@ -26,21 +26,15 @@ LanguagesNav.propTypes = {
26
26
} ;
27
27
28
28
export default class Popular extends React . Component {
29
- constructor ( props ) {
30
- super ( props ) ;
31
-
32
- this . state = {
33
- selectedLanguage : "All" ,
34
- repos : null ,
35
- error : null ,
36
- } ;
37
-
38
- this . updateLanguage = this . updateLanguage . bind ( this ) ;
39
- }
29
+ state = {
30
+ selectedLanguage : "All" ,
31
+ repos : null ,
32
+ error : null ,
33
+ } ;
40
34
componentDidMount ( ) {
41
35
this . updateLanguage ( this . state . selectedLanguage ) ;
42
36
}
43
- updateLanguage ( selectedLanguage ) {
37
+ updateLanguage = ( selectedLanguage ) => {
44
38
this . setState ( {
45
39
selectedLanguage,
46
40
error : null ,
@@ -60,7 +54,7 @@ export default class Popular extends React.Component {
60
54
error : `There was an error fetching the repositories` ,
61
55
} ) ;
62
56
} ) ;
63
- }
57
+ } ;
64
58
render ( ) {
65
59
const { selectedLanguage, repos, error } = this . state ;
66
60
Original file line number Diff line number Diff line change @@ -67,16 +67,12 @@ Card.propTypes = {
67
67
} ;
68
68
69
69
class Results extends React . Component {
70
- constructor ( props ) {
71
- super ( props ) ;
72
-
73
- this . state = {
74
- winner : null ,
75
- loser : null ,
76
- error : null ,
77
- loading : true ,
78
- } ;
79
- }
70
+ state = {
71
+ winner : null ,
72
+ loser : null ,
73
+ error : null ,
74
+ loading : true ,
75
+ } ;
80
76
componentDidMount ( ) {
81
77
const sp = this . props . router . searchParams ;
82
78
const playerOne = sp . get ( "playerOne" ) ;
Original file line number Diff line number Diff line change @@ -8,20 +8,14 @@ import Nav from "./components/Nav";
8
8
import Results from "./components/Results" ;
9
9
10
10
class App extends React . Component {
11
- constructor ( prop ) {
12
- super ( prop ) ;
13
-
14
- this . state = {
15
- theme : "light" ,
16
- } ;
17
-
18
- this . toggleTheme = this . toggleTheme . bind ( this ) ;
19
- }
20
- toggleTheme ( ) {
11
+ state = {
12
+ theme : "light" ,
13
+ } ;
14
+ toggleTheme = ( ) => {
21
15
this . setState ( ( { theme } ) => ( {
22
16
theme : theme === "light" ? "dark" : "light" ,
23
17
} ) ) ;
24
- }
18
+ } ;
25
19
render ( ) {
26
20
return (
27
21
< Router >
You can’t perform that action at this time.
0 commit comments