swiper
swiper copied to clipboard
Thumbs Module not working on Strict Mode
Check that this is really a bug
- [X] I confirm
Reproduction link
https://codesandbox.io/p/devbox/swiper-react-thumbs-gallery-forked-6j6tf2?file=%2Fsrc%2Fmain.jsx%3A7%2C37
Bug description
Running the Thumbs example using StrictMode and hydrateRoot breaks with Cannot convert undefined or null to object.
It seems this is due to Swiper instance being destroyed.
Expected Behavior
Thumbs works in strict mode
Actual Behavior
No response
Swiper version
11.1.3
Platform/Target and Browser Versions
macOS Chrome
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
- [X] Make sure this is a Swiper issue and not a framework-specific issue
Would you like to open a PR for this bug?
- [X] I'm willing to open a PR
same issue
Hi guys, any workaround for this?
the workaround is
thumbs={{ swiper: thumbsSwiper }}
replace to
thumbs={{ swiper: thumbsSwiper && !thumbsSwiper.destroyed ? thumbsSwiper : null }}