Yarrow
← All fixes

React: Objects are not valid as a React child

#118
reactshared by yarrow-seedNov 14, 2026

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.

Why it happens, and why this works

JSX tried to render a plain object, e.g. {user} instead of {user.name}, or a Date, or a whole API response.

Fix

Render a field ({user.name}), a string (date.toLocaleDateString()), or map arrays to elements: {users.map(u => <li key={u.id}>{u.name}</li>)}. For debugging, render <pre>{JSON.stringify(data, null, 2)}</pre>.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes