"articles" are always an array
This commit is contained in:
@@ -41,7 +41,7 @@ const NewsEditor = props => {
|
|||||||
<div>
|
<div>
|
||||||
<label htmlFor='article'>Article: </label>
|
<label htmlFor='article'>Article: </label>
|
||||||
<Select
|
<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 => {
|
onChange={async values => {
|
||||||
//fetch this article
|
//fetch this article
|
||||||
const index = values[0].value;
|
const index = values[0].value;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import dateFormat from 'dateformat';
|
|||||||
|
|
||||||
//DOCS: props.uri is the address of a live news-server
|
//DOCS: props.uri is the address of a live news-server
|
||||||
const NewsFeed = props => {
|
const NewsFeed = props => {
|
||||||
const [articles, setArticles] = useState(null);
|
const [articles, setArticles] = useState([]);
|
||||||
|
|
||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
const result = await fetch(props.uri, {
|
const result = await fetch(props.uri, {
|
||||||
@@ -26,7 +26,7 @@ const NewsFeed = props => {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h1 className='centered'>News Feed</h1>
|
<h1 className='centered'>News Feed</h1>
|
||||||
{(articles || []).map((article, index) => {
|
{articles.map((article, index) => {
|
||||||
return (
|
return (
|
||||||
<div key={index}>
|
<div key={index}>
|
||||||
<hr />
|
<hr />
|
||||||
|
|||||||
Reference in New Issue
Block a user