{"record":{"id":"4da66eb61a8aedd1","repo":"facebook/react","slug":"link-is-a-self-closing-tag-and-must-neither-have","errorCode":null,"errorMessage":"link is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.","messagePattern":"link 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":3111,"sourceCode":"  }\n}\n\nfunction pushLinkImpl(\n  target: Array<Chunk | PrecomputedChunk>,\n  props: Object,\n): null {\n  target.push(startChunkForTag('link'));\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            `${'link'} is a self-closing tag and must neither have \\`children\\` nor ` +\n              'use `dangerouslySetInnerHTML`.',\n          );\n        default:\n          pushAttribute(target, propKey, propValue);\n          break;\n      }\n    }\n  }\n\n  // Link never participate as a ViewTransition\n\n  target.push(endOfStartTagSelfClosing);\n  return null;\n}\n\nfunction pushStyle(\n  target: Array<Chunk | PrecomputedChunk>,","sourceCodeStart":3093,"sourceCodeEnd":3129,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js#L3093-L3129","documentation":"Thrown by pushStartLink when a <link> element carries a non-null children or dangerouslySetInnerHTML prop. <link> is a void/self-closing element (no end tag in HTML), so children would be dropped by the parser and innerHTML has no content slot; React throws during serialization instead of silently emitting broken markup.","triggerScenarios":"JSX like <link rel=\"stylesheet\" href=\"x\">fallback</link>, or spreading a props object containing children onto <link rel=\"icon\" ... />, or attempting dangerouslySetInnerHTML on it.","commonSituations":"Spread props in SEO/head-manager components (next/head-style utilities, custom Meta components) accidentally including children; HTML-to-JSX conversion of <link>...</link>; attempting to inline CSS 'into' a stylesheet link.","solutions":["Self-close the link and drop the children: <link rel=\"stylesheet\" href=\"x\" />","Destructure children out before spreading: const {children, ...rest} = props; <link {...rest} />","If you meant to inline styles, use <style dangerouslySetInnerHTML={{__html: css}} /> instead"],"exampleFix":"// before\n<link rel=\"stylesheet\" href=\"/app.css\">fallback</link>\n\n// after\n<link rel=\"stylesheet\" href=\"/app.css\" />","handlingStrategy":"type-guard","validationCode":"const {children, dangerouslySetInnerHTML, ...linkProps} = props;\nreturn <link {...linkProps} />;","typeGuard":"type LinkProps = JSX.IntrinsicElements['link'] & {children?: never; dangerouslySetInnerHTML?: never};","tryCatchPattern":null,"preventionTips":["Always self-close <link />","In head/meta-manager components, strip children from spread props","Use <style dangerouslySetInnerHTML> for inline CSS, never a link"],"tags":["ssr","link","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"}