File tree 4 files changed +73
-2
lines changed
4 files changed +73
-2
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import './App.css' ;
3
+ import Stories from './Stories' ;
4
+
5
+ const App = ( { stories } ) =>
6
+ < div className = "app" >
7
+ < Stories stories = { stories } />
8
+ </ div >
9
+
10
+ export default App ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import './Stories.css' ;
3
+ import Story from './Story' ;
4
+
5
+ const Stories = ( { stories } ) =>
6
+ < div className = "stories" >
7
+ { ( stories || [ ] ) . map ( story =>
8
+ < Story
9
+ key = { story . objectID }
10
+ story = { story }
11
+ />
12
+ ) }
13
+ </ div >
14
+
15
+ export default Stories ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import './Story.css' ;
3
+
4
+ const Story = ( { story } ) => {
5
+ const {
6
+ title,
7
+ url,
8
+ author,
9
+ num_comments,
10
+ points,
11
+ } = story ;
12
+
13
+ return (
14
+ < div className = "story" >
15
+ < span >
16
+ < a href = { url } > { title } </ a >
17
+ </ span >
18
+ < span > { author } </ span >
19
+ < span > { num_comments } </ span >
20
+ < span > { points } </ span >
21
+ </ div >
22
+ ) ;
23
+ }
24
+
25
+ export default Story ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import ReactDOM from 'react-dom' ;
3
3
import './index.css' ;
4
- import App from './App' ;
4
+ import App from './components/ App' ;
5
5
import registerServiceWorker from './registerServiceWorker' ;
6
6
7
- ReactDOM . render ( < App /> , document . getElementById ( 'root' ) ) ;
7
+ const stories = [
8
+ {
9
+ title : 'React' ,
10
+ url : 'https://facebook.github.io/react/' ,
11
+ author : 'Jordan Walke' ,
12
+ num_comments : 3 ,
13
+ points : 4 ,
14
+ objectID : 0 ,
15
+ } , {
16
+ title : 'Redux' ,
17
+ url : 'https://github.com/reactjs/redux' ,
18
+ author : 'Dan Abramov, Andrew Clark' ,
19
+ num_comments : 2 ,
20
+ points : 5 ,
21
+ objectID : 1 ,
22
+ } ,
23
+ ] ;
24
+
25
+ ReactDOM . render (
26
+ < App stories = { stories } /> ,
27
+ document . getElementById ( 'root' )
28
+ ) ;
8
29
registerServiceWorker ( ) ;
You can’t perform that action at this time.
0 commit comments