mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
2e35238d65
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.
13 lines
274 B
TypeScript
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;
|