Search code examples
reactjscarouselmaterializeautoplay

React Materialize Carousel Autoplay


Given the code below, I would like to make the carousel autoplay within the said interval. However, being new in React, I have no idea on how to do it. I have tried searching for answers and have tried using carousel('next'), it didn't work. I am still finding answers and is hoping to clear this problem. Thanks!

import React from 'react';
import { Carousel } from 'react-materialize';

const Header = () => {
const imgArr = [
'https://picsum.photos/200/300?image=0',
'https://picsum.photos/200/300?image=1',
'https://picsum.photos/200/300?image=2',
];

return (
<Carousel
  className='tabs'
  options={{ duration: 100, indicators: true }}
  images={imgArr}
/>
);
);

Solution

  • You could use this plugin instead: http://www.linxtion.com/demo/react-image-gallery/

    You can use the prop slideInterval to decide when the next slide will occur.