{"record":{"id":"c78ad26f53602c2e","repo":"facebook/react","slug":"537","errorCode":"537","errorMessage":"Cannot pass event handlers (${propKey}) in renderToHTML because the HTML will never be hydrated so they can never get called.","messagePattern":"Cannot pass event handlers \\((.+?)\\) in renderToHTML because the HTML will never be hydrated so they can never get called\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-markup/src/ReactFizzConfigMarkup.js","lineNumber":129,"sourceCode":"  type: string,\n  props: Object,\n  resumableState: ResumableState,\n  renderState: RenderState,\n  preambleState: null | PreambleState,\n  hoistableState: null | HoistableState,\n  formatContext: FormatContext,\n  textEmbedded: boolean,\n): ReactNodeList {\n  for (const propKey in props) {\n    if (hasOwnProperty.call(props, propKey)) {\n      const propValue = props[propKey];\n      if (propKey === 'ref' && propValue != null) {\n        throw new Error(\n          'Cannot pass ref in renderToHTML because they will never be hydrated.',\n        );\n      }\n      if (typeof propValue === 'function') {\n        throw new Error(\n          'Cannot pass event handlers (' +\n            propKey +\n            ') in renderToHTML because ' +\n            'the HTML will never be hydrated so they can never get called.',\n        );\n      }\n    }\n  }\n\n  return pushStartInstanceImpl(\n    target,\n    type,\n    props,\n    resumableState,\n    renderState,\n    preambleState,\n    hoistableState,\n    formatContext,","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-markup/src/ReactFizzConfigMarkup.js#L111-L147","documentation":"experimental_renderToHTML emits inert HTML that will never be hydrated, so event handler props could never be invoked; the markup Fizz config throws whenever any host-element prop is a function, naming the offending propKey in the message. This is a deliberate guard that static output stays non-interactive.","triggerScenarios":"Passing a function prop (onClick, onChange, onSubmit, onPress, ...) to any host element inside the renderToHTML tree - including handlers deep inside reused client components or spread props objects.","commonSituations":"Dropping a client page/component into a static markup render; components with built-in onSubmit/onClick; spreading untyped props that carry handlers; migrating hydrated SSR code to renderToHTML.","solutions":["Remove function props from all elements rendered by renderToHTML.","Branch in shared components on a static/isStatic flag to omit handlers during static rendering.","Attach interactivity client-side: emit data-* attributes and call addEventListener after the HTML string is inserted into the document."],"exampleFix":"// before\nconst html = await experimental_renderToHTML(\n  <button onClick={save}>Save</button>,\n);\n\n// after\nconst html = await experimental_renderToHTML(\n  <button data-action='save'>Save</button>,\n);\n// after insertion:\ncontainer\n  .querySelector('[data-action=save]')\n  .addEventListener('click', save);","handlingStrategy":"validation","validationCode":"import {cloneElement, isValidElement} from 'react';\nfunction forStaticMarkup(node) {\n  if (Array.isArray(node)) return node.map(forStaticMarkup);\n  if (!isValidElement(node)) return node;\n  const next = {};\n  for (const key in node.props) {\n    const value = node.props[key];\n    if (key === 'ref' || typeof value === 'function') continue;\n    next[key] =\n      key === 'children' && value != null ? forStaticMarkup(value) : value;\n  }\n  return cloneElement(node, next);\n}\nconst html = await experimental_renderToHTML(forStaticMarkup(<App />));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass function props to host elements in a renderToHTML tree.","Add an isStatic branch to shared components to omit handlers during static rendering.","Use data-* attributes plus client-side addEventListener for interactivity on static HTML."],"tags":["event-handlers","rendertohtml","react-markup","static-markup"],"backgroundTag":"event-handlers-in-static-render","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}