{"record":{"id":"e3100fe407cca94b","repo":"facebook/react","slug":"input-is-a-self-closing-tag-and-must-neither-have","errorCode":null,"errorMessage":"input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.","messagePattern":"input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js","lineNumber":2529,"sourceCode":"  let formAction = null;\n  let formEncType = null;\n  let formMethod = null;\n  let formTarget = null;\n  let value = null;\n  let defaultValue = null;\n  let checked = null;\n  let defaultChecked = null;\n\n  for (const propKey in props) {\n    if (hasOwnProperty.call(props, propKey)) {\n      const propValue = props[propKey];\n      if (propValue == null) {\n        continue;\n      }\n      switch (propKey) {\n        case 'children':\n        case 'dangerouslySetInnerHTML':\n          throw new Error(\n            `${'input'} is a self-closing tag and must neither have \\`children\\` nor ` +\n              'use `dangerouslySetInnerHTML`.',\n          );\n        case 'name':\n          name = propValue;\n          break;\n        case 'formAction':\n          formAction = propValue;\n          break;\n        case 'formEncType':\n          formEncType = propValue;\n          break;\n        case 'formMethod':\n          formMethod = propValue;\n          break;\n        case 'formTarget':\n          formTarget = propValue;\n          break;","sourceCodeStart":2511,"sourceCodeEnd":2547,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js#L2511-L2547","documentation":"Thrown while serializing an <input> start tag in Fizz: the props loop hits a non-null children or dangerouslySetInnerHTML prop and throws. <input> is a void/self-closing element — HTML has no closing tag for it, so children would never be emitted and dangerouslySetInnerHTML has no target element content; React refuses rather than silently dropping them.","triggerScenarios":"JSX like <input type=\"text\">{value}</input> (JSX puts the text into props.children), or <input {...props} /> where the spread object carries a children key, or setting dangerouslySetInnerHTML on an input.","commonSituations":"Copy-pasting a textarea/input pattern and leaving children inside; spread props from a generic Field component that includes children; HTML-to-JSX converters emitting <input>...</input>.","solutions":["Make the input self-closing: <input type=\"text\" defaultValue={value} /> — put the value in value/defaultValue","Strip children before spreading: const {children, ...rest} = props; <input {...rest} />","If you were trying to prefill it, use the value or defaultValue prop instead"],"exampleFix":"// before\n<input type=\"text\">{value}</input>\n<input {...props} /> {/* props.children present */}\n\n// after\n<input type=\"text\" defaultValue={value} />\nconst {children, ...rest} = props;\n<input {...rest} />","handlingStrategy":"type-guard","validationCode":"const {children, dangerouslySetInnerHTML, ...inputProps} = props;\nif (__DEV__ && (children != null || dangerouslySetInnerHTML != null)) {\n  console.warn('<input> cannot have children or dangerouslySetInnerHTML');\n}\nreturn <input {...inputProps} />;","typeGuard":"type InputProps = JSX.IntrinsicElements['input'] & {children?: never; dangerouslySetInnerHTML?: never};","tryCatchPattern":null,"preventionTips":["Keep <input> self-closing in JSX; put values in value/defaultValue","Strip children/dangerouslySetInnerHTML keys from props objects before spreading onto void elements","Let TypeScript's JSX.IntrinsicElements typings flag children on void tags in .tsx files"],"tags":["ssr","input","void-element","children","dangerouslysetinnerhtml"],"backgroundTag":"void-element-children","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}