Search code examples
javascripthtmlreactjscarouselbootstrap-5

Set Active class for Bootstrap Carousel


Iam having a bootstrap carousel in which the images are dynamic(from backend api) so i could not set active class for the slides ..If i use active className in hardcode, all slides are active at same time .. How to do it dynamically

So far i have tried setting active class using jquery.. I got all the elements inside carousel-inner and then used addClass and removeClass but it did not help me

sandbox link click here


Solution

  • Don't use jquery in react project. take look on other npm

    https://www.npmjs.com/package/react-responsive-carousel

    and if you are using react-bootstrap then check

    https://react-bootstrap.github.io/components/carousel/