This shouldn't be an issue due to the dependancy array being empty but could be worth trying.
I'd also change the setBlog line as I'm not sure what effect lodash will have in setState. I'd do something like
const articles =_.get(_data, 'blog.articles', {});
setBlog(articles)
and of course change what you pass to Posts. Hope this helps
You could try moving takeBlog() inside the useEffect
useEffect(() => {
async function takeBlog(query) {
const data = await (await fetch(
${root}/api/blog/${query}
)).json();console.log(_data.blog)
setBlog(.get(_data, 'blog', {})); // *
}
takeBlog(query);
}, []);
This shouldn't be an issue due to the dependancy array being empty but could be worth trying.
I'd also change the setBlog line as I'm not sure what effect lodash will have in setState. I'd do something like
const articles =_.get(_data, 'blog.articles', {});
setBlog(articles)
and of course change what you pass to Posts. Hope this helps
stackoverflow.com/questions/533323...