View Single Post
Old 06-25-2025, 02:00 AM   #1
markstyne
Registered User
 
Join Date: Dec 2012
Location: Los Angeles
Posts: 210
Facing React Error: Objects are not valid as a React child.

Greetings Everyone! I am currently building a react website for a homeopathic doctor. We are currently working on a part where we have to display the information of homeopathic doctors from the JSON object, but I am getting an error:

Error: Objects are not valid as a React child (found: object with keys {name, degree, specialty}).

Here is the snippet of my component code:
const doctorInfo = {
name: "Dr. Sonal Mehta",
degree: "BHMS",
specialty: "Chronic Illnesses & Depression"
};

return (
<div>
<h2>{doctorInfo}</h2> {/* This line throws the error */}
</div>
);

I think it's related to the rendering of objects, but I am not sure how to fix it. Can anyone help me with the correct way of rendering the data in JSX? Your help will be beneficial.

Last edited by markstyne; 06-25-2025 at 02:04 AM..
markstyne is offline   Reply With Quote