Skip to content

[compiler]: add useWindowVirtualizer to known incompatible libraries - #36912

Merged
poteto merged 2 commits into
react:mainfrom
gtkatakura:compiler-add-usewindowvirtualizer-incompatible
Jul 6, 2026
Merged

poteto merged 2 commits into
react:mainfrom
gtkatakura:compiler-add-usewindowvirtualizer-incompatible

Conversation

@gtkatakura

@gtkatakura gtkatakura commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#34493 added @tanstack/react-virtual's useVirtualizer to the known incompatible libraries, but not useWindowVirtualizer.

Both hooks are thin wrappers around the same internal useVirtualizerBase, so they return the same referentially-stable virtualizer instance. Its methods (e.g. getVirtualItems(), getTotalSize()) return internally-mutated values rather than new ones, which is exactly the "interior mutability" pattern that breaks memoization described in the module type provider.

Because only useVirtualizer was registered, code using useWindowVirtualizer is silently compiled with the same unsafe memoization. In our app this froze getVirtualItems() to its first-render value (an empty [] before measurement), producing permanently-empty virtualized lists — the same class of bug #34493 fixed, just via the window variant.

This registers useWindowVirtualizer alongside useVirtualizer with the identical shape, in both implementations:

  • compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts
  • compiler/crates/react_compiler_hir/src/default_module_type_provider.rs (Rust port)

See also the community report referenced in #34493: TanStack/virtual#736 (comment)

How did you test this change?

Each addition mirrors the existing useVirtualizer entry exactly (same kind, params, return type, and knownIncompatible message shape); both are data-only additions to the module type providers, following the precedent set by #34493 which changed only the TS file. The Rust change keeps the two providers in sync.

@meta-cla

meta-cla Bot commented Jul 1, 2026

Copy link
Copy Markdown

Hi @gtkatakura!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Jul 1, 2026
@meta-cla

meta-cla Bot commented Jul 1, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

react#34493 added `@tanstack/react-virtual`'s `useVirtualizer` to the known
incompatible libraries, but not `useWindowVirtualizer`. Both hooks wrap the
same `useVirtualizerBase` and return a referentially-stable virtualizer whose
methods (e.g. `getVirtualItems()`, `getTotalSize()`) return internally-mutated
values, so `useWindowVirtualizer` breaks memoization in the same way.
…(Rust HIR)

Mirror the TS DefaultModuleTypeProvider change in the Rust port
(react_compiler_hir): register `useWindowVirtualizer` alongside
`useVirtualizer` for `@tanstack/react-virtual`. Both wrap the same
`useVirtualizerBase` and return a referentially-stable virtualizer whose
methods return internally-mutated values, so both break memoization.
@poteto
poteto force-pushed the compiler-add-usewindowvirtualizer-incompatible branch from eb6234d to 7079fb2 Compare July 6, 2026 23:31
@poteto

poteto commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

thanks!

@poteto
poteto merged commit 08725f2 into react:main Jul 6, 2026
19 checks passed
github-actions Bot pushed a commit that referenced this pull request Jul 6, 2026
#36912)

## Summary

#34493 added `@tanstack/react-virtual`'s `useVirtualizer` to the known
incompatible libraries, but not `useWindowVirtualizer`.

Both hooks are thin wrappers around the same internal
`useVirtualizerBase`, so they return the same referentially-stable
virtualizer instance. Its methods (e.g. `getVirtualItems()`,
`getTotalSize()`) return internally-mutated values rather than new ones,
which is exactly the "interior mutability" pattern that breaks
memoization described in the module type provider.

Because only `useVirtualizer` was registered, code using
`useWindowVirtualizer` is silently compiled with the same unsafe
memoization. In our app this froze `getVirtualItems()` to its
first-render value (an empty `[]` before measurement), producing
permanently-empty virtualized lists — the same class of bug #34493
fixed, just via the window variant.

This registers `useWindowVirtualizer` alongside `useVirtualizer` with
the identical shape, in **both** implementations:
-
`compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts`
-
`compiler/crates/react_compiler_hir/src/default_module_type_provider.rs`
(Rust port)

See also the community report referenced in #34493:
TanStack/virtual#736 (comment)

## How did you test this change?

Each addition mirrors the existing `useVirtualizer` entry exactly (same
kind, params, return type, and `knownIncompatible` message shape); both
are data-only additions to the module type providers, following the
precedent set by #34493 which changed only the TS file. The Rust change
keeps the two providers in sync.

DiffTrain build for [08725f2](08725f2)
github-actions Bot pushed a commit that referenced this pull request Jul 7, 2026
#36912)

## Summary

#34493 added `@tanstack/react-virtual`'s `useVirtualizer` to the known
incompatible libraries, but not `useWindowVirtualizer`.

Both hooks are thin wrappers around the same internal
`useVirtualizerBase`, so they return the same referentially-stable
virtualizer instance. Its methods (e.g. `getVirtualItems()`,
`getTotalSize()`) return internally-mutated values rather than new ones,
which is exactly the "interior mutability" pattern that breaks
memoization described in the module type provider.

Because only `useVirtualizer` was registered, code using
`useWindowVirtualizer` is silently compiled with the same unsafe
memoization. In our app this froze `getVirtualItems()` to its
first-render value (an empty `[]` before measurement), producing
permanently-empty virtualized lists — the same class of bug #34493
fixed, just via the window variant.

This registers `useWindowVirtualizer` alongside `useVirtualizer` with
the identical shape, in **both** implementations:
-
`compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts`
-
`compiler/crates/react_compiler_hir/src/default_module_type_provider.rs`
(Rust port)

See also the community report referenced in #34493:
TanStack/virtual#736 (comment)

## How did you test this change?

Each addition mirrors the existing `useVirtualizer` entry exactly (same
kind, params, return type, and `knownIncompatible` message shape); both
are data-only additions to the module type providers, following the
precedent set by #34493 which changed only the TS file. The Rust change
keeps the two providers in sync.

DiffTrain build for [08725f2](08725f2)
github-actions Bot pushed a commit to code/lib-react that referenced this pull request Jul 8, 2026
react#36912)

## Summary

react#34493 added `@tanstack/react-virtual`'s `useVirtualizer` to the known
incompatible libraries, but not `useWindowVirtualizer`.

Both hooks are thin wrappers around the same internal
`useVirtualizerBase`, so they return the same referentially-stable
virtualizer instance. Its methods (e.g. `getVirtualItems()`,
`getTotalSize()`) return internally-mutated values rather than new ones,
which is exactly the "interior mutability" pattern that breaks
memoization described in the module type provider.

Because only `useVirtualizer` was registered, code using
`useWindowVirtualizer` is silently compiled with the same unsafe
memoization. In our app this froze `getVirtualItems()` to its
first-render value (an empty `[]` before measurement), producing
permanently-empty virtualized lists — the same class of bug react#34493
fixed, just via the window variant.

This registers `useWindowVirtualizer` alongside `useVirtualizer` with
the identical shape, in **both** implementations:
-
`compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts`
-
`compiler/crates/react_compiler_hir/src/default_module_type_provider.rs`
(Rust port)

See also the community report referenced in react#34493:
TanStack/virtual#736 (comment)

## How did you test this change?

Each addition mirrors the existing `useVirtualizer` entry exactly (same
kind, params, return type, and `knownIncompatible` message shape); both
are data-only additions to the module type providers, following the
precedent set by react#34493 which changed only the TS file. The Rust change
keeps the two providers in sync.

DiffTrain build for [08725f2](react@08725f2)
github-actions Bot pushed a commit to code/lib-react that referenced this pull request Jul 8, 2026
react#36912)

## Summary

react#34493 added `@tanstack/react-virtual`'s `useVirtualizer` to the known
incompatible libraries, but not `useWindowVirtualizer`.

Both hooks are thin wrappers around the same internal
`useVirtualizerBase`, so they return the same referentially-stable
virtualizer instance. Its methods (e.g. `getVirtualItems()`,
`getTotalSize()`) return internally-mutated values rather than new ones,
which is exactly the "interior mutability" pattern that breaks
memoization described in the module type provider.

Because only `useVirtualizer` was registered, code using
`useWindowVirtualizer` is silently compiled with the same unsafe
memoization. In our app this froze `getVirtualItems()` to its
first-render value (an empty `[]` before measurement), producing
permanently-empty virtualized lists — the same class of bug react#34493
fixed, just via the window variant.

This registers `useWindowVirtualizer` alongside `useVirtualizer` with
the identical shape, in **both** implementations:
-
`compiler/packages/babel-plugin-react-compiler/src/HIR/DefaultModuleTypeProvider.ts`
-
`compiler/crates/react_compiler_hir/src/default_module_type_provider.rs`
(Rust port)

See also the community report referenced in react#34493:
TanStack/virtual#736 (comment)

## How did you test this change?

Each addition mirrors the existing `useVirtualizer` entry exactly (same
kind, params, return type, and `knownIncompatible` message shape); both
are data-only additions to the module type providers, following the
precedent set by react#34493 which changed only the TS file. The Rust change
keeps the two providers in sync.

DiffTrain build for [08725f2](react@08725f2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants