-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import './App.css'; | ||
import Stories from './Stories'; | ||
|
||
const App = ({ stories }) => | ||
<div className="app"> | ||
<Stories stories={stories} /> | ||
</div> | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import './Stories.css'; | ||
import Story from './Story'; | ||
|
||
const Stories = ({ stories }) => | ||
<div className="stories"> | ||
{(stories || []).map(story => | ||
<Story | ||
key={story.objectID} | ||
story={story} | ||
/> | ||
)} | ||
</div> | ||
|
||
export default Stories; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import './Story.css'; | ||
|
||
const Story = ({ story }) => { | ||
const { | ||
title, | ||
url, | ||
author, | ||
num_comments, | ||
points, | ||
} = story; | ||
|
||
return ( | ||
<div className="story"> | ||
<span> | ||
<a href={url}>{title}</a> | ||
</span> | ||
<span>{author}</span> | ||
<span>{num_comments}</span> | ||
<span>{points}</span> | ||
</div> | ||
); | ||
} | ||
|
||
export default Story; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
import App from './App'; | ||
import App from './components/App'; | ||
import registerServiceWorker from './registerServiceWorker'; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
const stories = [ | ||
{ | ||
title: 'React', | ||
url: 'https://facebook.github.io/react/', | ||
author: 'Jordan Walke', | ||
num_comments: 3, | ||
points: 4, | ||
objectID: 0, | ||
}, { | ||
title: 'Redux', | ||
url: 'https://github.com/reactjs/redux', | ||
author: 'Dan Abramov, Andrew Clark', | ||
num_comments: 2, | ||
points: 5, | ||
objectID: 1, | ||
}, | ||
]; | ||
|
||
ReactDOM.render( | ||
<App stories={stories} />, | ||
document.getElementById('root') | ||
); | ||
registerServiceWorker(); |