laurenchen0631 / react-owl-carousel

React + Owl Carousel
Apache License 2.0
198 stars 109 forks source link

Not able to update state variable on onChanged callback , gives error 'unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering' #103

Open jinojacob15 opened 3 years ago

jinojacob15 commented 3 years ago

const handleAfterChange = event => { const { index } = event.item; setActiveSlideIndex(itemCount); };

const customSettings = { autoplay: false, dots: true, callbacks: true, onChange: event => handleAfterChange(event) };

Above code produces error ! DeepinScreenshot_select-area_20210730124100

timsewellatom commented 3 years ago

I've been battling the same problem and using React.memo to wrap the OwlCarousel component seems to have fixed it.