-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swiper instance: Cannot read properties of undefined (reading 'slideChange') with React 18 #5635
Comments
Would be good to see live example with the issue (without Next, as it could be a problem), so far I couldn't replicate it |
Hello @b-novikov-ipersonality. Please provide a online reproduction by codesandbox or a minimal GitHub repository. You can fork one of our demos in codesandbox to get start. Issues labeled by |
@nolimits4web I updated repository that is in reproduction link $ git clone [email protected]:b-novikov-ipersonality/swiper-react18-bug.git
$ cd swiper-react18-bug
$ yarn
$ yarn start |
Would be still good to see issue in code sandbox as you can see all works correctly here https://codesandbox.io/s/swiper-default-react-forked-wxrchz?file=/src/App.jsx, try also to remove React.StrictMode |
@nolimits4web, problem is only reproducible with Strict mode enabled. But in my opinion removing strict mode shouldn't be a permanent solution because strict mode helps here and there in development. |
Hi @b-novikov-ipersonality , were you able to address this issue without disabling strict mode? |
@vandreleal hey. It was fixed by @nolimits4web. ...
if (swiper && !swiper.destroyed) {...}
... |
for me there was slightly different error of |
@krystiangryczon have you found a workaround or solution? |
Check that this is really a bug
Reproduction link
upd: https://github.com/b-novikov-ipersonality/swiper-react18-bug
Bug description
After initializing swiper instance by passing
<Swiper>
componentsetState
function, when using any of the swiper instance events, for exampleor any other, I get runtime error:
TypeError: Cannot read properties of undefined (reading 'activeIndexChange')
error img
Note that Swiper has many problems with React 18, among them #5613 #5630 #5609 so it's probably some form of incompatibility with react 18. Maybe until the fix is released you should make Swiper require react <18.0.0?
Steps to reproduce:
Expected Behavior
I can use event listeners on swiper instances without error
Actual Behavior
When using event listeners on swiper instance error
TypeError: Cannot read properties of undefined (reading 'event_name')
occur whereevent_name
is the name of the used eventSwiper version
"^8.1.1"
Platform/Target and Browser Versions
linux, chrome Version 100.0.4896.88 (Official Build) (64-bit)
Validations
Would you like to open a PR for this bug?
The text was updated successfully, but these errors were encountered: