@samitouri / QOS-React / commits / e12b0bdc3b

[compiler]: add `@tanstack/react-virtual` to known incompatible libraries (#34493)

Replaces #31820. #34027 added a check for `@tanstack/react-table`, but not `@tanstack/react-virtual`. In our testing `@tanstack/react-virtual`'s `useVirtualizer` returns functions that cannot be memoized, [this is also documented in the community](https://github.com/TanStack/virtual/issues/736#issuecomment-3065658277).

Cody Olsen committed Sep 15, 2025 at 20:53 UTC e12b0bdc3b976cc2431ccf30126cf339be83720c
1 file changed +18
compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts
+18
@@ -86,6 +86,24 @@ export function defaultModuleTypeProvider(
86 },
87 };
88 }
89 + case '@tanstack/react-virtual': {
90 + return {
91 + kind: 'object',
92 + properties: {
93 + /*
94 + * Many of the properties of `useVirtualizer()`'s return value are incompatible, so we mark the entire hook
95 + * as incompatible
96 + */
97 + useVirtualizer: {
98 + kind: 'hook',
99 + positionalParams: [],
100 + restParam: Effect.Read,
101 + returnType: {kind: 'type', name: 'Any'},
102 + knownIncompatible: `TanStack Virtual's \`useVirtualizer()\` API returns functions that cannot be memoized safely`,
103 + },
104 + },
105 + };
106 + }
107 }
108 return null;
109 }