i'm currently working with react project, which gets data from api and show it on the console.
although i wrote the console.log() just one time inside the useEffect hooks (with the [articles] dependency ), the web browser's console.log always shows the console.log two times like this: enter image description here
but i don't know reason why..
in my thought when the 'articles' state set by first useEffect hook, the second useEffect hook activates and console.log should be run only one time.. but it didn't.
here is my code
const NewsList = () => {
const [articles, setArticles] = useState([]);
useEffect(()=> {
const getData = async () => {
const response = await axios.get(`https://newsapi.org/v2/top-headlines?country=kr&apiKey=''
`);
setArticles(response.data.articles);
}
getData();
},[])
useEffect(()=> {
console.log(articles);
},[articles])
return (
<div className="newsListBlock">
<NewsArticle article={article}></NewsArticle>
<NewsArticle article={article}></NewsArticle>
<NewsArticle article={article}></NewsArticle>
<NewsArticle article={article}></NewsArticle>
<NewsArticle article={article}></NewsArticle>
</div>
);
};