Skip to content

Commit e12b0bd

Browse files
authored
[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](TanStack/virtual#736 (comment)).
1 parent 92d7ad5 commit e12b0bd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ export function defaultModuleTypeProvider(
8686
},
8787
};
8888
}
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+
}
89107
}
90108
return null;
91109
}

0 commit comments

Comments
 (0)