Files
oxc-project__oxc/crates/oxc_react_compiler/fixtures/infer-forwardref-callback-with-non-ref-param.tsx
Boshen 2e35238d65 fix(react-compiler): compile forwardRef callbacks with non-ref param names (#25468)
The discovery walker let a declarator name flow through `forwardRef`/`memo` calls, so `const Foo = forwardRef((props, viewTracker) => ...)` was treated as a named component and rejected by the component param check (a second param must look like a ref). Upstream only names a function from its direct parent (declarator/assignment/property); a function in call arguments is anonymous and is detected through the forwardRef/memo callback branch, which never checks params.

Fixes the two Simorgh files from the ecosystem comparison (`TopStoriesItem`, `LatestMediaItem`): both now compile with output matching upstream, including identical memo cache sizes. Adds a fixture for the pattern; no existing fixture snapshots change.

Created with assistance from Claude.
2026-08-10 08:54:59 +00:00

13 lines
274 B
TypeScript

// @compilationMode:"infer"
import { forwardRef } from 'react';
type Props = { text: string };
const TopStoriesItem = forwardRef<HTMLDivElement, Props>(
({ text }, viewTracker) => {
return <div ref={viewTracker}>{text}</div>;
},
);
export default TopStoriesItem;