diff --git a/src/components/carousel/index.tsx b/src/components/carousel/index.tsx index e4aa1cb..d5f22a2 100644 --- a/src/components/carousel/index.tsx +++ b/src/components/carousel/index.tsx @@ -52,28 +52,27 @@ export const Carousel: FunctionComponent = (userProps: CarouselPr const autoSwipeTimer = useRef(); const isNavigation = typeof props.navigation === 'function'; - if (props.dynamic) { - useEffect(() => { - const newItems = updateNodes( - itemsRef.current, - props.children, - prevChildren, - props.slide, - props.infinite, - ); + useEffect(() => { + if (props.dynamic) return + const newItems = updateNodes( + itemsRef.current, + props.children, + prevChildren, + props.slide, + props.infinite, + ); - setItems(newItems); - itemsRef.current = newItems; - if ( - page < props.pageCount && - prevChildren && - prevChildren?.length < props.children.length - ) { - slide(SlideDirection.Right); - setPage(page + 1); - } - }, [props.children]); - } + setItems(newItems); + itemsRef.current = newItems; + if ( + page < props.pageCount && + prevChildren && + prevChildren?.length < props.children.length + ) { + slide(SlideDirection.Right); + setPage((page: number) => page + 1); + } + }, [ props.dynamic, props.children, props.slide, props.infinite, props.pageCount ]); useEffect(() => { autoSwipe();