Error: Objects are not valid as React child

preview_player
Показать описание
In this beginner level React tutorial, we discuss how to research and solve a common React bug.
Рекомендации по теме
Комментарии
Автор

I was already familiar with this error, but I love that you are doing these topics!

PierreGadea
Автор

Thank you very much i wasted 2 hours solving this your video game me way to think and implement

SingleAAkash
Автор

This happened to me when I was tryna display a list of categories by creating an array and diff objects in it with title and id and using the map property and was rendering it through a diff component by rendering the component and passing the prop called title and when I accepted prop from the other component and rendered {title } but it didn't work but when I accepted the prop in {} object form and it worked I don't know why btw I'm very new to react.

dopeenough
Автор

For me this happens when i am inputting a number, the page just goes blank, i ama beginner please help

shelbyjackson
Автор

It happened to me when I wanted to filter my posts displayed on my website. I had the posts in the state as an array of objects and then in my own "postFilter" function, I first filtered the posts according to the filter set by the user "eg. title = something" and stored the returned contents in a local array. Then I mapped that array so that it contained JSX objects with the correct props.
However to my 2 hour long dismay I had this error, despite the fact that the array that I was trying to render was an array of JSX and not normal objects...
Finally I fixed it by first mapping the state into JSX objects and then filtering them. It works, but I have no idea why...
What is the difference between filter and map? Is it important somehow which one I call first?

MiSt
Автор

Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it. please fix

thugsoftechnology