[Solved] react18 swiper Error: Cannot read properties of undefined (reading ‘wrapperClass’)

Using swiperjs in nextjs, after upgrading the react version to 18.x, an error is reported:

Cannot read properties of undefined (reading ‘wrapperClass’)

Current version information:

"next": "^12.1.7-canary.30",
"react": "^18.2.0-next-e531a4a62-20220505",
"react-dom": "^18.2.0-next-e531a4a62-20220505",
"swiper": "^7.4.1"

Solution: Via the settings next.config.jsinreactStrictMode : false

or:

Upgrade swiper to the latest version

"next": "^12.1.7-canary.30",
"react": "^18.2.0-next-e531a4a62-20220505",
"react-dom": "^18.2.0-next-e531a4a62-20220505",
"swiper": "^8.2.2"

See More: Swiper crashing with React 18 + Strict Mode

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *