Skip to main content

Manual Control

Manual control navigation items Controller

If you want to automatically jump to the specified page slideToPage when retrieving API data, please set the isUseAnimation parameter with false

import BearCarousel, {Controller, ICarouselState} from 'bear-react-carousel';
import {useState} from 'react';

const SyncCarousel = () => {
const [controller, setController] = useState<Controller>();
const [carouselState, setCarouselState] = useState<ICarouselState>();


useEffect(() => {
handleSlide(4, false);

}, [controller]);

const handleSlide = (page: number, isUseAnimation = true) => {
controller?.slideToPage(page, isUseAnimation);
}

return <div>
<BearCarousel
// ...ignore some
onSlideChange={setCarouselState}
setController={setController}
/>

currentPage: {carouselState?.page.total}
</div>
}

Try click button