{"record":{"id":"a1baa0cedaf92e12","repo":"facebook/react","slug":"if-you-supply-defaultvalue-on-a-textarea-do-n","errorCode":null,"errorMessage":"If you supply `defaultValue` on a <textarea>, do not pass children.","messagePattern":"If you supply `defaultValue` on a <textarea>, do not pass children\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js","lineNumber":2809,"sourceCode":"  if (value === null && defaultValue !== null) {\n    value = defaultValue;\n  }\n\n  pushViewTransitionAttributes(target, formatContext);\n\n  target.push(endOfStartTag);\n\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);","sourceCodeStart":2791,"sourceCodeEnd":2827,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js#L2791-L2827","documentation":"Thrown by pushStartTextArea when a <textarea> has both children and a non-null value (which includes a defaultValue, since value falls back to defaultValue a few lines above). React historically allowed children as the default content of a textarea, but combining that with an explicit value/defaultValue is ambiguous, so SSR throws. A DEV-only console.error ('Use the defaultValue or value props instead of setting children on <textarea>') fires for any children usage even before this check.","triggerScenarios":"Server-rendering <textarea defaultValue=\"x\">content</textarea>, <textarea value={v} onChange={...}>{initial}</textarea>, or a spread that supplies children alongside value/defaultValue.","commonSituations":"HTML-to-JSX converters that keep the textarea's inner text as children while a wrapper adds defaultValue; copy-paste of placeholder-like initial content; components forwarding both a value prop and children into a textarea.","solutions":["Delete the children and keep value/defaultValue as the single source: <textarea defaultValue=\"x\" />","If children was meant as initial content, move that string into defaultValue","In generic components, destructure children out before spreading props onto <textarea>"],"exampleFix":"// before\n<textarea defaultValue=\"Initial\">Initial</textarea>\n\n// after\n<textarea defaultValue=\"Initial\" />","handlingStrategy":"validation","validationCode":"function getTextareaValue(props: {children?: unknown; value?: string; defaultValue?: string}): string | undefined {\n  if (props.children != null && (props.value != null || props.defaultValue != null)) {\n    throw new TypeError('Pass defaultValue/value or children on <textarea>, not both');\n  }\n  return props.value ?? props.defaultValue ?? (typeof props.children === 'string' ? props.children : undefined);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set textarea content through value/defaultValue, never children","Heed the DEV warning 'Use the `defaultValue` or `value` props instead of setting children on <textarea>' — it precedes the throw","In wrappers, map an incoming children string to defaultValue yourself"],"tags":["ssr","textarea","children","defaultvalue"],"backgroundTag":"textarea-children-misuse","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}