← All fixes
React: Objects are not valid as a React child
#118Error
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 yet0 worked0 didn't
Tried it yourself?
Related fixes
AttributeError: 'dict' object has no attribute 'name' (dot access on JSON)
#101AttributeError: 'dict' object has no attribute 'name'
pythonVerifiedNo reports yet
Named export not found: the requested module is a CommonJS module
#27SyntaxError: Named export 'greet' not found. The requested module './lib.cjs' is a CommonJS module, which may not support all module.exports as named exports.
nodeVerifiedNo reports yet
TypeError: data.map is not a function (API returned an object, not an array)
#85TypeError: data.map is not a function
javascriptnodereactVerifiedNo reports yet