From 8bca346f8d27e942f2dfbe5cd2607f302e93b635 Mon Sep 17 00:00:00 2001 From: "Fabien S." Date: Tue, 3 Sep 2024 10:22:07 +0200 Subject: [PATCH] fix item height detection Get the height of the item after the dom has been render --- src/components/CarouselItem.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/CarouselItem.tsx b/src/components/CarouselItem.tsx index 0470776..e95c555 100644 --- a/src/components/CarouselItem.tsx +++ b/src/components/CarouselItem.tsx @@ -65,7 +65,7 @@ export const CarouselItem = ({ animation, next, prev, swipe, state, index, maxIn }, [setHeight, state.active, index, divRef]) // Set height on every child change - useEffect(() => + useLayoutEffect(() => { checkAndSetHeight(); @@ -148,4 +148,4 @@ export const CarouselItem = ({ animation, next, prev, swipe, state, index, maxIn ) -} \ No newline at end of file +}