"articles" are always an array

This commit is contained in:
2021-03-11 14:58:24 +11:00
parent 8f3ab27106
commit 9b6c5af09d
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ const NewsEditor = props => {
<div>
<label htmlFor='article'>Article: </label>
<Select
options={(articles).map(article => { return { label: article.title, value: article.index }; })}
options={articles.map(article => { return { label: article.title, value: article.index }; })}
onChange={async values => {
//fetch this article
const index = values[0].value;
+2 -2
View File
@@ -3,7 +3,7 @@ import dateFormat from 'dateformat';
//DOCS: props.uri is the address of a live news-server
const NewsFeed = props => {
const [articles, setArticles] = useState(null);
const [articles, setArticles] = useState([]);
useEffect(async () => {
const result = await fetch(props.uri, {
@@ -26,7 +26,7 @@ const NewsFeed = props => {
return (
<div>
<h1 className='centered'>News Feed</h1>
{(articles || []).map((article, index) => {
{articles.map((article, index) => {
return (
<div key={index}>
<hr />