-
-
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 crashing with React 18 + Strict Mode #5398
Comments
I tried as follows Using swiper in nextjs, when upgrading next and react to the latest version, an error is reported Cannot read properties of undefined (reading 'wrapperClass') The relevant dependency information is as follows:
The above problem can be solved when the When you don't want to modify the strict mode of react, you can try to upgrade the swiper to the latest version, and it can be used normally
|
Hello folks, I'm testing the latest version of this lib (8.4.6) with the latest version of React (18.2.0) and RemixJS (1.11.0) but I'm still getting this error:
Can you reopen this issue please? I need to support this current configuration: import { RemixBrowser } from '@remix-run/react';
import { startTransition, StrictMode } from 'react';
import { hydrateRoot } from 'react-dom/client';
function hydrate() {
startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>
);
});
}
if (window.requestIdleCallback) {
window.requestIdleCallback(hydrate);
} else {
// Safari doesn't support requestIdleCallback
// https://caniuse.com/requestidlecallback
window.setTimeout(hydrate, 1);
} Any help is really appreciated! |
Swiper 9.0.2 + React 18.2.0 in StrictMode
|
Previous one was not described well... New one with link to sanbox here: #6342 |
I'm using version 6.8.4 because it doesn't require esm packages, I also need strict mode, but I get this very error, how can I get rid of it?
|
Server Error This error happened while generating the page. Any console logs will be displayed in the terminal window. |
React 18.3.1 Cannot convert undefined or null to object
} export default CarouselView;` |
@vanditpatel22 I just ran into this issue in local development with the thumbs module (presumably because of react strict mode). I found that I need to use some check like:
Otherwise, the swiper instance that may be passed could be destroyed, and such an instance does not have the expected properties for the thumbs module to use during its update. |
Reproduction link
https://codesandbox.io/s/swiper-react-18-gf9bq
Bug description
When using Swiper React with React 18 (currently in RC, to be released soon) and Strict Mode, it crash with the following error:
Basically the swiper object gets destroyed() somewhere, and when in the Swiper class (core/core.js)
mount()
gets called and tries to accessthis.params
, the swiper object contains nothing else but{ destroyed: true }
, so the hereinabove error is thrown.To reproce it:
yarn add react@rc react-dom@rc
)ReactDOM.render(REACT_NODE, HTML_ROOT)
toReactDOM.createRoot(HTML_ROOT).render(REACT_NODE)
<React.StrictMode></React.StrictMode>
(1) About concurrent mode: it's possible to use the normal mode, but then React 18 issue the following deprecation message:
Swiper version
7.4.1
Platform/Target and Browser Versions
Linux, Chrome 99.0 (shouldn't matter).
Validations
The text was updated successfully, but these errors were encountered: