AllenYuan

pagination - add pagination to articlelist

Apr 19th, 2020
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import ArticlePreview from './ArticlePreview';
  2. import ListPagination from './ListPagination';
  3. import React from 'react';
  4.  
  5. const ArticleList = props => {
  6.   if (!props.articles) {
  7.     return (
  8.       <div className="article-preview">Loading...</div>
  9.     );
  10.   }
  11.  
  12.   if (props.articles.length === 0) {
  13.     return (
  14.       <div className="article-preview">
  15.         No articles are here... yet.
  16.       </div>
  17.     );
  18.   }
  19.  
  20.   return (
  21.     <div>
  22.       {
  23.         props.articles.map(article => {
  24.           return (
  25.             <ArticlePreview article={article} />
  26.           );
  27.         })
  28.       }
  29.  
  30.       <ListPagination
  31.         articlesCount={props.articlesCount}
  32.         currentPage={props.currentPage}
  33.         onSetPage={props.onSetPage} />
  34.     </div>
  35.   );
  36. };
  37.  
  38. export default ArticleList;
Advertisement
Add Comment
Please, Sign In to add comment