Skip to content
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 9.0.2 + React 18.2.0 in StrictMode - Cannot read properties of undefined (reading 'slideClass') #6342

Closed
5 of 6 tasks
ScorpAL opened this issue Feb 3, 2023 · 1 comment
Labels

Comments

@ScorpAL
Copy link
Contributor

ScorpAL commented Feb 3, 2023

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/s/swiper-9-react-strict-issue-c83d98

Bug description

Swiper 9.0.2 + React 18.2.0 in StrictMode

If you set loading='lazy' to image element inside SwiperSlide and set React.StrictMode you will see error message

Uncaught TypeError: Cannot read properties of undefined (reading 'slideClass')
    at slideSelector (process-lazy-preloader.js:2:1)
    at processLazyPreloader (process-lazy-preloader.js:3:1)
    at HTMLImageElement.<anonymous> (core.js:484:1)

const slideSelector = () => (swiper.isElement ? `swiper-slide` : `.${swiper.params.slideClass}`);

I know that lazy loading reimplemented in Swiper 9.

Is it possible to avoid execution of processLazyPreloader if developer don't want to use preloader spinners?

Expected Behavior

Native lazy loading working without issues in console in React.StrictMode

Actual Behavior

Errors in console:

Uncaught TypeError: Cannot read properties of undefined (reading 'slideClass')
    at slideSelector (process-lazy-preloader.js:2:1)
    at processLazyPreloader (process-lazy-preloader.js:3:1)
    at HTMLImageElement.<anonymous> (core.js:484:1)

Swiper version

9.0.2

Platform/Target and Browser Versions

Win/Mac, Chrome

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
@nolimits4web
Copy link
Owner

fixed in 4ea0102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants