Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   Programming General (http://siteownersforums.com/forumdisplay.php?f=44)
-   -   Facing React Error: Objects are not valid as a React child. (http://siteownersforums.com/showthread.php?t=985647)

markstyne 06-25-2025 02:00 AM

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 (

{doctorInfo}

{/* This line throws the error */}

);

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.


All times are GMT -7. The time now is 10:14 AM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.