my data is not mapping into component. “error message is: TypeError: Cannot read property ‘map’ of undefined”
code below:
import React, { useEffect, useState } from 'react';
import { getNews } from '../news-api';
import NewsCard from "./NewsCard.js";
function NewsContainer() {
const [ news, setNews] = useState([]);
useEffect(()=>{ getNews().then(data=>setNews(data));
},[]);
return news.map(article => <NewsCard props={article} />
)
}
export default NewsContainer