@@ -15,17 +15,20 @@ export default class HomePage extends React.PureComponent { // eslint-disable-li
1515 * when initial state username is not null, submit the form to load repos
1616 */
1717 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 ( ) ;
2021 }
2122 }
2223
2324 render ( ) {
24- const { loading, error, repos } = this . props ;
25+ const {
26+ loading, error, repos, username, onChangeUsername, onSubmitForm
27+ } = this . props ;
2528 const reposListProps = {
2629 loading,
2730 error,
28- repos,
31+ repos
2932 } ;
3033
3134 return (
@@ -37,20 +40,22 @@ export default class HomePage extends React.PureComponent { // eslint-disable-li
3740 < div className = "home-page" >
3841 < section className = "centered" >
3942 < 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 >
4146 </ section >
4247 < section >
4348 < h2 > Try me!</ h2 >
44- < form onSubmit = { this . props . onSubmitForm } >
49+ < form onSubmit = { onSubmitForm } >
4550 < label htmlFor = "username" >
46- Show Github repositories by
51+ Show Github repositories by
4752 < span className = "at-prefix" > @</ span >
4853 < input
4954 id = "username"
5055 type = "text"
5156 placeholder = "flexdinesh"
52- value = { this . props . username }
53- onChange = { this . props . onChangeUsername }
57+ value = { username }
58+ onChange = { onChangeUsername }
5459 />
5560 </ label >
5661 </ form >
@@ -64,15 +69,9 @@ export default class HomePage extends React.PureComponent { // eslint-disable-li
6469
6570HomePage . propTypes = {
6671 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 ] ) ,
7574 onSubmitForm : PropTypes . func ,
7675 username : PropTypes . string ,
77- onChangeUsername : PropTypes . func ,
76+ onChangeUsername : PropTypes . func
7877} ;
0 commit comments