{"record":{"id":"f459b1090bc61d4e","repo":"facebook/react","slug":"textarea-can-only-have-at-most-one-child","errorCode":null,"errorMessage":"<textarea> can only have at most one child.","messagePattern":"<textarea> can only have at most one child\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js","lineNumber":2816,"sourceCode":"\n  // TODO (yungsters): Remove support for children content in <textarea>.\n  if (children != null) {\n    if (__DEV__) {\n      console.error(\n        'Use the `defaultValue` or `value` props instead of setting ' +\n          'children on <textarea>.',\n      );\n    }\n\n    if (value != null) {\n      throw new Error(\n        'If you supply `defaultValue` on a <textarea>, do not pass children.',\n      );\n    }\n\n    if (isArray(children)) {\n      if (children.length > 1) {\n        throw new Error('<textarea> can only have at most one child.');\n      }\n\n      // TODO: remove the coercion and the DEV check below because it will\n      // always be overwritten by the coercion several lines below it. #22309\n      if (__DEV__) {\n        checkHtmlStringCoercion(children[0]);\n      }\n      value = '' + children[0];\n    }\n    if (__DEV__) {\n      checkHtmlStringCoercion(children);\n    }\n    value = '' + children;\n  }\n\n  if (typeof value === 'string' && value[0] === '\\n') {\n    // text/html ignores the first character in these tags if it's a newline\n    // Prefer to break application/xml over text/html (for now) by adding","sourceCodeStart":2798,"sourceCodeEnd":2834,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js#L2798-L2834","documentation":"Thrown by pushStartTextArea when a <textarea> receives an array of children with more than one element. A textarea holds a single text value; multiple children (e.g. <textarea>{['a', 'b']}</textarea> or several expressions inside the tag) cannot be unambiguously combined, so Fizz throws while serializing.","triggerScenarios":"JSX like <textarea>{str}{' suffix'}</textarea>, <textarea>{lines}</textarea> where lines is an array of length > 1, or a children array produced by mapping data inside the tag.","commonSituations":"Rendering dynamic multi-part strings inside <textarea> (e.g. {user.name}{'\\n'}{user.bio}); JSX whitespace/JSX.text fragments that fold into arrays; converted HTML with mixed content inside the tag.","solutions":["Build one string first, then render it: <textarea defaultValue={`${user.name}\\n${user.bio}`} />","Join arrays explicitly: <textarea defaultValue={lines.join('\\n')} />","Keep a single expression child at most inside <textarea>"],"exampleFix":"// before\n<textarea>{user.name}{'\\n'}{user.bio}</textarea>\n\n// after\n<textarea defaultValue={`${user.name}\\n${user.bio}`} />","handlingStrategy":"validation","validationCode":"const initialValue = Array.isArray(children) ? children.join('') : children;\nif (Array.isArray(children) && children.length > 1) {\n  // join explicitly instead of letting React see multiple children\n}\nreturn <textarea defaultValue={String(initialValue)} />;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Render at most one expression inside <textarea>","Flatten/join multi-part strings before passing them as children","Prefer defaultValue with a precomputed string over JSX children for textareas"],"tags":["ssr","textarea","children","jsx"],"backgroundTag":"textarea-children-misuse","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}