File tree Expand file tree Collapse file tree 5 files changed +52
-73
lines changed
Expand file tree Collapse file tree 5 files changed +52
-73
lines changed Original file line number Diff line number Diff line change 1- import React , { Component } from 'react' ;
1+ import React from 'react' ;
22import './App.css' ;
33
44import Stories from './Stories' ;
55import SearchStories from './SearchStories' ;
66
7- class App extends Component {
8- render ( ) {
9- return (
10- < div className = "app" >
11- < div className = "interactions" >
12- < SearchStories />
13- </ div >
14- < Stories />
15- </ div >
16- ) ;
17- }
18- }
7+ const App = ( ) =>
8+ < div className = "app" >
9+ < div className = "interactions" >
10+ < SearchStories />
11+ </ div >
12+ < Stories />
13+ </ div >
1914
2015export default App ;
Original file line number Diff line number Diff line change @@ -30,6 +30,5 @@ const Button = ({
3030export default Button ;
3131
3232export {
33- Button ,
3433 ButtonInline ,
3534} ;
Original file line number Diff line number Diff line change 11import React , { Component } from 'react' ;
22import { connect } from 'react-redux' ;
33import { doFetchStories } from '../actions/story' ;
4- import { Button } from './Buttons' ;
4+ import Button from './Buttons' ;
55
66const applyQueryState = query => ( ) => ( {
77 query
Original file line number Diff line number Diff line change 1- import React , { Component } from 'react' ;
1+ import React from 'react' ;
22import { connect } from 'react-redux' ;
33import { getReadableStories } from '../selectors/story' ;
44import './Stories.css' ;
@@ -27,25 +27,18 @@ const COLUMNS = {
2727 } ,
2828} ;
2929
30- class Stories extends Component {
31- render ( ) {
32- const { stories } = this . props ;
30+ const Stories = ( { stories } ) =>
31+ < div className = "stories" >
32+ < StoriesHeader columns = { COLUMNS } />
3333
34- return (
35- < div className = "stories" >
36- < StoriesHeader columns = { COLUMNS } />
37-
38- { ( stories || [ ] ) . map ( story =>
39- < Story
40- key = { story . objectID }
41- story = { story }
42- columns = { COLUMNS }
43- />
44- ) }
45- </ div >
46- ) ;
47- }
48- }
34+ { ( stories || [ ] ) . map ( story =>
35+ < Story
36+ key = { story . objectID }
37+ story = { story }
38+ columns = { COLUMNS }
39+ />
40+ ) }
41+ </ div >
4942
5043const StoriesHeader = ( { columns } ) =>
5144 < div className = "stories-header" >
Original file line number Diff line number Diff line change 1- import React , { Component } from 'react' ;
1+ import React from 'react' ;
22import { connect } from 'react-redux' ;
33import { doArchiveStory } from '../actions/archive' ;
44import './Story.css' ;
55
66import { ButtonInline } from './Buttons' ;
77
8- class Story extends Component {
9- render ( ) {
10- const {
11- story,
12- columns,
13- onArchive,
14- } = this . props ;
8+ const Story = ( { story, columns, onArchive } ) => {
9+ const {
10+ title,
11+ url,
12+ author,
13+ num_comments,
14+ points,
15+ objectID,
16+ } = story ;
1517
16- const {
17- title,
18- url,
19- author,
20- num_comments,
21- points,
22- objectID,
23- } = story ;
24-
25- return (
26- < div className = "story" >
27- < span style = { { width : columns . title . width } } >
28- < a href = { url } > { title } </ a >
29- </ span >
30- < span style = { { width : columns . author . width } } >
31- { author }
32- </ span >
33- < span style = { { width : columns . comments . width } } >
34- { num_comments }
35- </ span >
36- < span style = { { width : columns . points . width } } >
37- { points }
38- </ span >
39- < span style = { { width : columns . archive . width } } >
40- < ButtonInline onClick = { ( ) => onArchive ( objectID ) } >
41- Archive
42- </ ButtonInline >
43- </ span >
44- </ div >
45- ) ;
46- }
18+ return (
19+ < div className = "story" >
20+ < span style = { { width : columns . title . width } } >
21+ < a href = { url } > { title } </ a >
22+ </ span >
23+ < span style = { { width : columns . author . width } } >
24+ { author }
25+ </ span >
26+ < span style = { { width : columns . comments . width } } >
27+ { num_comments }
28+ </ span >
29+ < span style = { { width : columns . points . width } } >
30+ { points }
31+ </ span >
32+ < span style = { { width : columns . archive . width } } >
33+ < ButtonInline onClick = { ( ) => onArchive ( objectID ) } >
34+ Archive
35+ </ ButtonInline >
36+ </ span >
37+ </ div >
38+ ) ;
4739}
4840
4941const mapDispatchToProps = dispatch => ( {
You can’t perform that action at this time.
0 commit comments