Emiliano-Bucci / react-spring-carousel-js

A new Carousel experience for the modern Web
https://react-spring-carousel-js.emilianobucci.com
80 stars 6 forks source link

Cannot read property 'split' of undefined #6

Closed thomasgrivet closed 3 years ago

thomasgrivet commented 3 years ago

Hello!

First of all, thanks a lot for this awesome project! I used to work with other carousel components like react-slick and such but this one it simply the best anyone can use IMO. I just have a single problem with the function 'slideToNextItem' that I use in a simple useEffect to automatically slide to the next item every X seconds. It works fine when the tab is opened and focused, but as soon as I change tab and comes back I have the following error:

Screenshot 2021-04-18 at 15 06 05

Do you have any idea what could cause this? As far as I understand, the issue comes from the getWrapperFromValue function.

Thanks a lot!

Emiliano-Bucci commented 3 years ago

@thomasgrivet Hi, thanks a lot for the feedback :) Regarding the issue, I've tried a very simple example using setInterval, triggering slideToNextItem every 1000ms (I've also tried different cases) but I couldn't reproduce it; could you please share to me a code snippet or something?

In any case, I was thinking to monitor the visibilityChange event and disable the carousel animation if the document is hidden to prevent strange behaviors when using setInterval. Let me know :)

thomasgrivet commented 3 years ago

Hello! Thanks for the answer! I ended up checking for document.hidden before triggering slideToNextItem as a quick fix 🙂 I will try to post a codesandbox example tomorrow!

Emiliano-Bucci commented 3 years ago

Thanks! I would like to investigate a bit to see if there's some dirty bug somewhere.

Emiliano-Bucci commented 3 years ago

@thomasgrivet I've spotted a possible case that was causing your bug; if you can, please try to update to the latest version - 1.7.5 - and see if the issue is still reproducible.

thomasgrivet commented 3 years ago

@thomasgrivet I've spotted a possible case that was causing your bug; if you can, please try to update to the latest version - 1.7.5 - and see if the issue is still reproducible.

I don't have / could not reproduce the issue anymore, thanks for the quick update! Really appreciate it!

Have a nice week!