{"record":{"id":"2b282210c7b74d03","repo":"facebook/react","slug":"objects-are-not-valid-as-a-react-child-found-c","errorCode":null,"errorMessage":"Objects are not valid as a React child (found: ${childrenString}). If you meant to render a collection of children, use an array instead.","messagePattern":"Objects are not valid as a React child \\(found: (.+?)\\)\\. If you meant to render a collection of children, use an array instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react/src/ReactChildren.js","lineNumber":334,"sourceCode":"          nextName,\n          callback,\n        );\n      }\n    } else if (type === 'object') {\n      if (typeof (children as any).then === 'function') {\n        return mapIntoArray(\n          resolveThenable(children as any),\n          array,\n          escapedPrefix,\n          nameSoFar,\n          callback,\n        );\n      }\n\n      // eslint-disable-next-line react-internal/safe-string-coercion\n      const childrenString = String(children as any);\n\n      throw new Error(\n        `Objects are not valid as a React child (found: ${\n          childrenString === '[object Object]'\n            ? 'object with keys {' +\n              Object.keys(children as any).join(', ') +\n              '}'\n            : childrenString\n        }). ` +\n          'If you meant to render a collection of children, use an array ' +\n          'instead.',\n      );\n    }\n  }\n\n  return subtreeCount;\n}\n\ntype MapFunc = (child: ?React$Node, index: number) => ?ReactNodeList;\n","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react/src/ReactChildren.js#L316-L352","documentation":"While traversing/mapPing a children collection, React hit a plain object that is not a renderable type (not an element, string, number, etc.). Objects cannot be rendered, and their string form ('[object Object]') would silently render garbage, so React throws and lists the object's keys to help identify it.","triggerScenarios":"Passing a plain object literal as a child: <div>{{a: 1}}</div>; rendering an API response object directly ({...JSON.parse(body)}); putting a Map/Set/window or class instance in JSX children, which then flows through React.Children.map/mapIntoArray.","commonSituations":"Rendering data from fetch/axios before extracting a field (data instead of data.title); interpolating an options object into JSX; children computed by a helper that returns an object instead of an element or string.","solutions":["Render a specific property or stringify deliberately: <div>{String(obj)}</div> or JSON.stringify if debugging","Extract the field you meant: {user.name} instead of {user}","For collections, render an array of elements with keys (or React.Children utilities) instead of the raw object"],"exampleFix":"// before\nconst user = await fetchUser(); // {name: 'Ada'}\nreturn <li>{user}</li>; // throws: object with keys {name}\n\n// after\nreturn <li>{user.name}</li>;","handlingStrategy":"type-guard","validationCode":"// Filter children to renderable primitives before rendering\nconst renderable = (v: unknown): boolean =>\n  v == null || ['string', 'number', 'boolean'].includes(typeof v) ||\n  (typeof v === 'object' && (v.$$typeof !== undefined || Array.isArray(v)));\nconst safeChildren = React.Children.toArray(children).filter(renderable);","typeGuard":"const isRenderableChild = (v: unknown): boolean =>\n  v == null ||\n  typeof v === 'string' ||\n  typeof v === 'number' ||\n  (typeof v === 'object' && !!(v as any).$$typeof); // React element","tryCatchPattern":null,"preventionTips":["Always extract the specific field from data objects before interpolating into JSX","Type children props (React.ReactNode) so object children fail at compile time","Remember Date/Map/Set/window are objects too — convert explicitly (date.toISOString(), Array.from(map))"],"tags":["react-children","invalid-child","jsx","objects-as-children"],"backgroundTag":"invalid-react-child-type","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}