Skip to content

Commit

Permalink
flushsync
Browse files Browse the repository at this point in the history
  • Loading branch information
jonelantha committed Jun 28, 2024
1 parent c2b3988 commit 60200e4
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useLayoutEffect, useRef } from 'react';
import { flushSync } from 'react-dom';

export function useResizeNotifier(
element: Element | undefined,
Expand Down Expand Up @@ -32,7 +33,7 @@ function withResizeLoopDetection(callback: () => void) {

const rectsBefore = elements.map(element => element.getBoundingClientRect());

callback();
flushSync(callback);

const rectsAfter = elements.map(element => element.getBoundingClientRect());

Expand Down

0 comments on commit 60200e4

Please sign in to comment.