Files
bun-src/test/bundler/transpiler/react-compiler-fixtures/allow-reassignment-to-global-function-jsx-prop.expect.md
2026-08-27 21:09:14 +00:00

1005 B

Input

function Component() {
  const onClick = () => {
    // Cannot assign to globals
    someUnknownGlobal = true;
    moduleLocal = true;
  };
  // It's possible that this could be an event handler / effect function,
  // but we don't know that and optimistically assume it will only be
  // called by an event handler or effect, where it is allowed to modify globals
  return <div onClick={onClick} />;
}

export const FIXTURE_ENTRYPOINT = {
  fn: Component,
  params: [{}],
};

Code

import { c as _c } from "react/compiler-runtime";
function Component() {
  const $ = _c(1);
  const onClick = _temp;
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = <div onClick={onClick} />;
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  return t0;
}
function _temp() {
  someUnknownGlobal = true;
  moduleLocal = true;
}

export const FIXTURE_ENTRYPOINT = {
  fn: Component,
  params: [{}],
};

Eval output

(kind: ok)