← All errors · Next.js
Objects are not valid as a React child
Exact error
Error: Objects are not valid as a React child (found: object with keys {id, name}). If you meant to render a collection of children, use an array instead.What it means
JSX tried to render a plain object. React can render strings, numbers, elements and arrays, but not objects.
Likely causes
- Rendering {user} instead of {user.name}.
- Rendering a Date object or a Promise.
- Rendering an error object directly.
How to fix it
Render a specific field or convert to a string:
<p>{user.name}</p> <p>{date.toLocaleDateString()}</p> <pre>{JSON.stringify(data, null, 2)}</pre>In client components, make sure you are not rendering a Promise from an un-awaited async call.
Related errors
- Too many re-renders. React limits the number of renders to prevent an infinite loop
- async/await is not yet supported in Client Components
Get new fixes weekly
No spam. Unsubscribe anytime. Privacy