Objects Are Not Valid As A React Child Data From Mongodb
I'm working on a project that uses Flask as a backend and sends data from MongoDB database and sends it to React to print on the screen. In the Flash file @app.route('/') @app.rout
Solution 1:
You're getting that error because you're trying to render a plain object. This isn't allowed. You need to render a string, an element, or some other valid type.
I'm assuming that since you're using h3 tags you want to put the object's title in that spot. You could do something like
<h3>{this.state.myData.title}</h3>
if myData
is a single object (I can't quite tell from your code). If myData
is an array of objects, you could do something like:
render() {
returnthis.state.myData.map(item => {
return (
<divkey={item._id}><h3>{item.title}</h3><p>{item.description}</p></div>
);
})
}
}
Post a Comment for "Objects Are Not Valid As A React Child Data From Mongodb"