@@ -198,8 +198,8 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
198
198
199
199
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear.
200
200
let lastContentSize = useRef < Size | null > ( null ) ;
201
- let [ , setUpdate ] = useState ( { } ) ;
202
- let queuedUpdateSize = useRef ( false ) ;
201
+ let [ update , setUpdate ] = useState ( { } ) ;
202
+
203
203
useLayoutEffect ( ( ) => {
204
204
if ( ! isUpdatingSize . current && ( lastContentSize . current == null || ! contentSize . equals ( lastContentSize . current ) ) ) {
205
205
// React doesn't allow flushSync inside effects, so queue a microtask.
@@ -212,23 +212,21 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
212
212
if ( typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined' ) {
213
213
// Queue call of updateSize to happen in a separate render but within the same act so that RAC virtualized ComboBoxes and Selects
214
214
// work properly
215
- queuedUpdateSize . current = true ;
216
215
setUpdate ( { } ) ;
217
216
lastContentSize . current = contentSize ;
218
- return ;
217
+ return
219
218
} else {
220
219
queueMicrotask ( ( ) => updateSize ( flushSync ) ) ;
221
220
}
222
221
}
223
222
224
- if ( queuedUpdateSize . current ) {
225
- queuedUpdateSize . current = false ;
226
- updateSize ( fn => fn ( ) ) ;
227
- }
228
-
229
223
lastContentSize . current = contentSize ;
230
224
} ) ;
231
225
226
+ useLayoutEffect ( ( ) => {
227
+ updateSize ( fn => fn ( ) ) ;
228
+ } , [ update ] )
229
+
232
230
let onResize = useCallback ( ( ) => {
233
231
updateSize ( flushSync ) ;
234
232
} , [ updateSize ] ) ;
0 commit comments