You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 90197d9
Browse filesBrowse the repository at this point in the historyBrowse files
fix(react-virtual): skip flushSync for notifies raised inside _willUpdate
With a `useVirtualizerState` subscriber attached, `_willUpdate` publishes
an option change that moved the range. When that happens mid-scroll the
notify is sync, and the adapter called `flushSync` from inside a layout
effect, where React skips the flush and warns in development. Widen the
`measureElement` guard into a commit-window flag that also covers
`_willUpdate`, so those notifies use a plain re-render at the same sync
priority.
The changeset now also notes that, with a subscriber attached, an option
change that moves the range fires `onChange` when it is committed rather
than at the next scroll event.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: .changeset/use-virtualizer-state.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,3 +7,4 @@ Add a store interface to the `Virtualizer` and a `useVirtualizerState` hook for
7
7
8
8
-`virtualizer.subscribe(listener)` registers any number of change listeners, and `virtualizer.getState()` returns an immutable `{ virtualItems, totalSize, range, isScrolling, scrollDirection }` snapshot that keeps its identity until a field changes.
9
9
-`useVirtualizerState(virtualizer, selector?, isEqual?)` subscribes to that state through `useSyncExternalStore`. Values read through it stay live under the React Compiler, which can otherwise memoise `virtualizer.getVirtualItems()` on the stable instance. It works with both `useVirtualizer` and `useWindowVirtualizer`.
10
+
- While a listener is subscribed, an option change that moves the visible range (such as a new `count`) fires `onChange` when it is committed, rather than at the next scroll event.
0 commit comments