"articles" are always an array
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 />
|
||||
|
||||
Reference in New Issue
Block a user