From 60200e40bc19f4e9beb97e4e275127c6496049a8 Mon Sep 17 00:00:00 2001 From: jonelantha <57597570+jonelantha@users.noreply.github.com> Date: Fri, 28 Jun 2024 20:57:15 +0100 Subject: [PATCH] flushsync --- .../react-responsive-pagination/src/hooks/useResizeNotifier.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-responsive-pagination/src/hooks/useResizeNotifier.ts b/packages/react-responsive-pagination/src/hooks/useResizeNotifier.ts index d8dcbcd..41e8ef9 100644 --- a/packages/react-responsive-pagination/src/hooks/useResizeNotifier.ts +++ b/packages/react-responsive-pagination/src/hooks/useResizeNotifier.ts @@ -1,4 +1,5 @@ import { useLayoutEffect, useRef } from 'react'; +import { flushSync } from 'react-dom'; export function useResizeNotifier( element: Element | undefined, @@ -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());