File tree Expand file tree Collapse file tree 5 files changed +47
-18
lines changed
Expand file tree Collapse file tree 5 files changed +47
-18
lines changed Original file line number Diff line number Diff line change 1212 .contest-name {
1313 padding : 0.5em ;
1414 }
15+
16+ }
17+
18+ .link {
19+ cursor : pointer ;
1520}
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import Header from './Header' ;
3- import ContestPreview from './ContestPreview ' ;
3+ import ContestList from './ContestList ' ;
44
55class App extends React . Component {
66 state = {
@@ -17,11 +17,7 @@ class App extends React.Component {
1717 return (
1818 < div className = "App" >
1919 < Header message = { this . state . pageHeader } />
20- < div >
21- { this . state . contests . map ( contest =>
22- < ContestPreview key = { contest . id } { ...contest } />
23- ) }
24- </ div >
20+ < ContestList contests = { this . state . contests } />
2521 </ div >
2622 ) ;
2723 }
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import ContestPreview from './ContestPreview' ;
3+
4+ const ContestList = ( { contests} ) => (
5+ < div className = "ContestList" >
6+ { contests . map ( contest =>
7+ < ContestPreview key = { contest . id } { ...contest } />
8+ ) }
9+ </ div >
10+ ) ;
11+
12+ ContestList . propTypes = {
13+ contests : React . PropTypes . array
14+ } ;
15+
16+ export default ContestList ;
Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import React , { Component } from 'react' ;
22
3- const ContestPreview = ( contest ) => {
4- return (
5- < div className = "ContestPreview" >
6- < div className = "category-name" >
7- { contest . categoryName }
8- </ div >
9- < div className = "contest-name" >
10- { contest . contestName }
3+ class ContestPreview extends Component {
4+
5+ handleClick = ( ) => {
6+ console . log ( this . props . contestName ) ;
7+ }
8+
9+ render ( ) {
10+ return (
11+ < div className = "link ContestPreview" onClick = { this . handleClick } >
12+ < div className = "category-name" >
13+ { this . props . categoryName }
14+ </ div >
15+ < div className = "contest-name" >
16+ { this . props . contestName }
17+ </ div >
1118 </ div >
12- </ div >
13- ) ;
19+ ) ;
20+ }
21+ }
22+
23+ ContestPreview . propTypes = {
24+ categoryName : React . PropTypes . string . isRequired ,
25+ contestName : React . PropTypes . string . isRequired
1426} ;
1527
1628export default ContestPreview ;
You can’t perform that action at this time.
0 commit comments