Open vishuRizz opened 3 months ago
If i am not mistaken, this error message is indicating that an object with keys {likes, dislikes} is being passed as a React child. I would say just to ensure that the data fetched from the API is an array of objects that can be correctly mapped
If i am not mistaken, this error message is indicating that an object with keys {likes, dislikes} is being passed as a React child. I would say just to ensure that the data fetched from the API is an array of objects that can be correctly mapped
can you actually fix this?, couse when i inport the addApiContex fron react contex it shows that it aint a method
Alright i will try to help.
function handleApiButton() {
fetch('https://dummyjson.com/posts')
.then(res => res.json())
.then(obj => {
console.log(obj.posts);
addApiPosts(obj.posts);
});
}
<div className="alert alert-success reactions" role="alert">
This post has been reacted by {post.reactions.likes + post.reactions.dislikes || post.reactions} people.
</div>
i'm calling an API and the function from main context is not being called to the API call even when i am importing it using const { ... , ..... } = createContext(....) the error is as followed
(Uncaught Error: Objects are not valid as a React child (found: object with keys {likes, dislikes}). If you meant to render a collection of children, use an array instead.)
This happens when you click on the " FETCH DATA-POST FROM API" on the home page when no posts already exist.