File tree Expand file tree Collapse file tree 4 files changed +73
-2
lines changed Expand file tree Collapse file tree 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 11import React from 'react' ;
22import ReactDOM from 'react-dom' ;
33import './index.css' ;
4- import App from './App' ;
4+ import App from './components/ App' ;
55import registerServiceWorker from './registerServiceWorker' ;
66
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+ ) ;
829registerServiceWorker ( ) ;
You can’t perform that action at this time.
0 commit comments