Objects are not valid as a React child: how to fix it
BeginnerReact interview questionBy UIRound, updated 3 December 2026
Short answer
Objects are not valid as a React child means you put a value between JSX tags that React does not know how to display: usually a plain object, a Date or an Error. React can render elements, strings, numbers, arrays of those, and empty values like null. The message says what it found, such as object with keys {id, name}. Render one property, turn the value into a string, or map the data to elements.
What React can render
The React docs define a React node, the type of children, as an element, a string, a number, a portal, an empty node (null, undefined, true or false), or an array of React nodes. Anything else in a child position throws this 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.React has no single correct way to turn an arbitrary object into text, so it refuses instead of guessing. It is a thrown error, so the component tree crashes up to the nearest error boundary. In production it appears as minified React error #31.
Read the "found" part first
The text in brackets tells you what kind of value it was. React builds it with Object.prototype.toString:
| Message says | You rendered |
|---|---|
found: object with keys {id, name} |
A plain object. The keys tell you which one. |
found: [object Date] |
A Date |
found: [object Error] |
An Error object |
found: object with keys {} |
An empty object, often a default value |
Search your component for a variable whose shape matches those keys.
Cause 1: rendering the whole object
<p>Signed in as {user}</p> // throws
<p>Signed in as {user.name}</p> // worksThis is the case the React docs use in their own exercise for this error. Pick the property you meant to show.
Cause 2: a Date
<time>{post.createdAt}</time> // throws if createdAt is a DateFormat it into a string first. Intl.DateTimeFormat gives you locale-aware output:
const fmt = new Intl.DateTimeFormat("en-IN", { dateStyle: "medium" });
<time dateTime={post.createdAt.toISOString()}>
{fmt.format(post.createdAt)}
</time>A related exercise is Format relative times like "3 minutes ago" with Intl.RelativeTimeFormat.
Cause 3: an error object
{error && <p role="alert">{error}</p>} // throws: found [object Error]
{error && <p role="alert">{error.message}</p>} // worksCause 4: an object where you expected an array
APIs often wrap lists: { items: [...], total: 42 }. Rendering the wrapper, or calling .map on the wrong level, leads here. Render the list inside it, and give each element a key:
<ul>
{data.items.map((item) => (
<li key={item.id}>{item.name}</li>
))}
</ul>If the data really is a keyed object, turn it into an array with Object.entries:
{Object.entries(scores).map(([player, score]) => (
<li key={player}>{player}: {score}</li>
))}Why lists need keys in React explains why each element needs one.
Cause 5: double curly braces in text
<h1>{{ title }}</h1> // throws: found object with keys {title}
<h1>{title}</h1> // works{{ }} is not special JSX syntax. It is an object inside curly braces, which is right for style={{ color: "red" }} but wrong for text. Vue and Angular templates use double braces for text, which makes this slip easy when you switch.
Cause 6: an object passed as children
<Card>{{ title: "Plan", price: 499 }}</Card>If Card renders {children}, React receives the object. Pass data as props instead (<Card title="Plan" price={499} />), or let the parent pass ready-made elements. Remove prop drilling without context: pass elements through children and slot props practises the second approach.
Quick debugging
To see what you have, render it as text temporarily:
<pre>{JSON.stringify(value, null, 2)}</pre>JSON.stringify returns a string, so React can show it. Use it to inspect, then render the real fields.
Common follow-up questions
Why does an array work when an object does not?
An array is an ordered list of children, which React already understands. An object has no order or display format that React could assume.
What is "Functions are not valid as a React child"?
A sibling warning. It appears when you render a component or function without calling or rendering it, for example {Header} instead of <Header />.
Can I render a Map or a Set?
Convert it first, for example [...map].map(([key, value]) => <li key={key}>{value}</li>). Mapping to elements with keys is clearer than relying on how React treats iterables.
Does TypeScript catch this?
Often, yes, because children are typed as ReactNode and a plain object does not match that type. Values typed as any, such as untyped API responses, slip through.
Mistakes to avoid
Rendering a
Date,Erroror API response object directlyUsing
{{ value }}in text out of habit from other template languagesLeaving
JSON.stringifyin production UI instead of rendering real fieldsTyping API data as
any, which hides the problem until runtimeMapping to elements without a
key
Sources
Practise it in code
Interviewers rarely stop at the definition. These questions open in an editor with tests.
- Implement a minimal React-like renderer with virtual DOM diffing and keyed reconciliationHard75 minFree
- Fix list items that keep the wrong state after reordering (index keys)Medium25 min
- Format relative times like "3 minutes ago" with
Intl.Easy20 minRelativeTimeFormat - Remove prop drilling without context: pass elements through
childrenand slot propsMedium30 min