Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import ArticlePreview from './ArticlePreview';
- const ArticleList = (props) => {
- // no articles => render loading text
- if (!props.articles) {
- return <div className="article-preview">Loading...</div>;
- }
- // no articles => render no articles text
- if (props.articles.length === 0) {
- return <div className="article-preview">No articles are here...yet.</div>;
- }
- // have articles => map them to article preview components
- return (
- <div>
- {props.articles.map((article) => {
- return <ArticlePreview article={article} key={article.slug} />
- })}
- </div>
- );
- };
- export default ArticleList;
Advertisement
Add Comment
Please, Sign In to add comment