Objects Are Not Valid as a
React Child — Error Explained
React 19 • Next.js 15 • TypeScript • Vite • React Router • Redux Toolkit
🧩 What Does “Objects Are Not Valid as a React Child” Mean?
The “Objects are not valid as a React child” error is one of the most common rendering errors in React. It occurs when you try to render a JavaScript object directly inside JSX, and React doesn't know how to display it.
The full error message reads:
Objects are not valid as a React child (found: object with keys { name, age, ... }).
If you meant to render a collection of children, use an array instead.
Why does this happen? React can only render primitive values
(strings, numbers, booleans, null, undefined) and
React elements (JSX). When you try to render a plain object, React throws this
error because it doesn't know how to display it.
⚡ Quick Reference — Common Causes at a Glance
{user} instead of {user.name} in JSX.{items} where items is an array of objects.Date or Map.React.createElement as a child.🧩 Detailed Breakdown — Every Cause Solved
Each card below dives deep into one specific cause of the "Objects are not valid as a React child" error, with root causes, code examples, and step-by-step fixes.
🛡️ Prevention — Avoid the Object Rendering Error
Instead of
{user}, use {user.name} or {user.email}.
Never render a raw object.
If you need to inspect an object, use
<pre>{JSON.stringify(data, null, 2)}</pre>.
Use
.map() to convert arrays of objects into arrays of React elements.
Before rendering, verify that your API response has the shape you expect. Use
data?.property optional chaining.
TypeScript can catch object rendering errors at compile time by enforcing proper types in your JSX.
❓ Frequently Asked Questions
React can render the following types as children:
- Primitives: strings, numbers, booleans (
true/falseare rendered as"true"/"false") - Null/Undefined: render nothing
- React elements:
<div>...</div> - Arrays of valid children:
[<span>A</span>, <span>B</span>] - Fragments:
<>...</>
Cannot render: plain objects, Date, Map,
Set, Promise, or functions.
Yes! You must use .map() to convert each
object into a React element.
// ✅ Correct — mapping array of objects
const users = [{ name: 'John' }, { name: 'Jane' }];
return (
<div>
{users.map(user => (
<span key={user.name}>{user.name}</span>
))}
</div>
);
key prop — always add
a unique key when mapping to avoid React warnings.
No. React 19 has the same rendering rules as React 18.
Objects are still not valid as React children. The use hook
in React 19 doesn't change this — it's for promises and contexts.
Best practices for debugging:
- Use console.log:
console.log(data)to see the object structure. - Use JSON.stringify:
<pre>{JSON.stringify(data, null, 2)}</pre> - Check the shape: Use
Object.keys(data)to see what properties exist. - Use optional chaining:
data?.propertyto safely access nested properties. - Use TypeScript: Define interfaces for your API responses.
Yes. Common Redux-related causes include:
- Rendering the whole Redux state slice:
{user}instead of{user.name}. - Rendering an API response stored in Redux without accessing properties.
- Using
useSelectorthat returns an object and rendering it directly.
Fix: Always access the specific properties you need from the Redux state.
// ❌ Wrong — rendering the whole user object
const user = useSelector(state => state.user);
return <div>{user}</div>; // 💥 Error!
// ✅ Correct — render specific properties
const user = useSelector(state => state.user);
return <div>{user?.name} ({user?.email})</div>;
Date objects are also not valid as React children.
// ❌ Wrong — rendering Date object directly
const date = new Date();
return <div>{date}</div>; // 💥 Error!
// ✅ Correct — convert to string
return <div>{date.toLocaleDateString()}</div>;
// or
return <div>{date.toString()}</div>;
The same applies to Map, Set, Promise,
and other non-primitive objects.

0 Comments
thanks for your comments!