Loading...
Loading...
Error: Objects are not valid as a React child (found: object with keys {id, name})React can only render strings, numbers, arrays, and React elements. If you try to render a plain JavaScript object directly in JSX, React throws this error because it doesn't know how to display it.
Extract the string or number property from the object.
// ❌ Renders the whole object — crashes
<div>{user}</div>
// ✅ Render a specific property
<div>{user.name}</div>
<div>{user.email}</div>Call a formatting method before rendering.
// ❌ Crashes — Date is an object
<span>{new Date()}</span>
// ✅ Convert to string first
<span>{new Date().toLocaleDateString()}</span>To quickly inspect an object during development.
<pre>{JSON.stringify(myObject, null, 2)}</pre>