Guest User

Untitled

a guest
May 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import React from 'react';
  2.  
  3. class ArticleList extends Component {
  4. constructor(props) {
  5. super(props);
  6. }
  7.  
  8. renderArticles = () => {
  9. const { articles } = this.props;
  10. return articles.map((a) => {
  11. const {type} = a;
  12. if (type === 'FullArticle') {
  13. return (<FullArticle article={a} />)
  14. } else if (type === 'BreakingNews') {
  15. return (<BreakingNews article={a} />);
  16. } else if (type === 'HealthArticle') {
  17. return (<HealthArticle article={a} />)
  18. }
  19. return (<DefaultArticle article={a} />);
  20. });
  21. }
  22.  
  23. render() {
  24. return (
  25. <div id="articles-list">
  26. { this.renderArticles() }
  27. {<ArticleListSideBar />}
  28. </div>
  29. );
  30. }
  31. }
  32.  
  33. ArticleList.propTypes = {
  34. articles: PropTypes.arrayOf(PropTypes.articles),
  35. };
  36.  
  37. export default ArticleList;
Add Comment
Please, Sign In to add comment