reactjsswiper.jsautoplayreact-swiper

Swiper autoplay is not working in React.js


I have Swiper slider in react.js

<Swiper
    modules={[EffectFade, Pagination]} 
    effect="fade" 
    slidesPerView={1} 
    loop={true} 
    autoplay={{ delay: 4000 }}
    pagination={{
     clickable: true,
     type: 'bullets', // set pagination type to 'bullets'
     dynamicBullets: true // create dynamic number of dots based on number of slides
   }}>

but it is not working, I watched some video and it is exactly same but not working, I also tried setting autoplay to default true

autoplay={true}

but it is not working anyway. any tips?


Solution

  • for anyone out there having same problem. I imported these

    
    import SwiperCore from 'swiper'
    import { Autoplay } from 'swiper';
    

    and this did the job

    SwiperCore.use([Autoplay]);