@@ -15,17 +15,20 @@ export default class HomePage extends React.PureComponent { // eslint-disable-li
15
15
* when initial state username is not null, submit the form to load repos
16
16
*/
17
17
componentDidMount ( ) {
18
- if ( this . props . username && this . props . username . trim ( ) . length > 0 ) {
19
- this . props . onSubmitForm ( ) ;
18
+ const { username, onSubmitForm } = this . props ;
19
+ if ( username && username . trim ( ) . length > 0 ) {
20
+ onSubmitForm ( ) ;
20
21
}
21
22
}
22
23
23
24
render ( ) {
24
- const { loading, error, repos } = this . props ;
25
+ const {
26
+ loading, error, repos, username, onChangeUsername, onSubmitForm
27
+ } = this . props ;
25
28
const reposListProps = {
26
29
loading,
27
30
error,
28
- repos,
31
+ repos
29
32
} ;
30
33
31
34
return (
@@ -37,20 +40,22 @@ export default class HomePage extends React.PureComponent { // eslint-disable-li
37
40
< div className = "home-page" >
38
41
< section className = "centered" >
39
42
< h2 > Start your next react project in seconds</ h2 >
40
- < p > A minimal < i > React-Redux</ i > boilerplate with all the best practices</ p >
43
+ < p >
44
+ A minimal < i > React-Redux</ i > boilerplate with all the best practices
45
+ </ p >
41
46
</ section >
42
47
< section >
43
48
< h2 > Try me!</ h2 >
44
- < form onSubmit = { this . props . onSubmitForm } >
49
+ < form onSubmit = { onSubmitForm } >
45
50
< label htmlFor = "username" >
46
- Show Github repositories by
51
+ Show Github repositories by
47
52
< span className = "at-prefix" > @</ span >
48
53
< input
49
54
id = "username"
50
55
type = "text"
51
56
placeholder = "flexdinesh"
52
- value = { this . props . username }
53
- onChange = { this . props . onChangeUsername }
57
+ value = { username }
58
+ onChange = { onChangeUsername }
54
59
/>
55
60
</ label >
56
61
</ form >
@@ -64,15 +69,9 @@ export default class HomePage extends React.PureComponent { // eslint-disable-li
64
69
65
70
HomePage . propTypes = {
66
71
loading : PropTypes . bool ,
67
- error : PropTypes . oneOfType ( [
68
- PropTypes . object ,
69
- PropTypes . bool ,
70
- ] ) ,
71
- repos : PropTypes . oneOfType ( [
72
- PropTypes . array ,
73
- PropTypes . bool ,
74
- ] ) ,
72
+ error : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . bool ] ) ,
73
+ repos : PropTypes . oneOfType ( [ PropTypes . array , PropTypes . bool ] ) ,
75
74
onSubmitForm : PropTypes . func ,
76
75
username : PropTypes . string ,
77
- onChangeUsername : PropTypes . func ,
76
+ onChangeUsername : PropTypes . func
78
77
} ;
0 commit comments