how call OwlCarousel react Method

Hi I use OwlCarousel React and I need call Method
but I don’t any idea to call the Method
please help me
https://github.com/laurenchen0631/react-owl-carousel

Answer

step 1 – In your constructor create the options object which will be passed to OwnCaroussel in step 2

constructor() { super(); this.options = { onInitialized: function(){ this.carousel = this; } };

Step 2 – Pass options to OwlCarousel as follows
<OwlCarousel {…this.options}>

Step 3 – now you can call any of carousel’s methods – For an example –

this.carousel.next() or this.carousel.prev() etc.

Leave a Reply

Your email address will not be published. Required fields are marked *