A
A
Alexey Arnaut2021-10-20 00:15:42
React
Alexey Arnaut, 2021-10-20 00:15:42

I can't figure out where this error comes from.

I'm working on a project to search for movies on React. Popular movies/serials, etc. are displayed, which you can click on and get to another page with information about them. It seems everything is fine and works, but when you click on some movies, an error flies

TypeError: Cannot read properties of undefined (reading 'classList')
at dom7.esm.js:243
at r.forEach (<anonymous>)
at r.addClass (dom7.esm.js:240)
at e.updateSlidesClasses (updateSlidesClasses.js:19)
at e.slideTo (slideTo.js:150)
at e.i.init (core-class.js:532)
at Object.el (init-swiper.js:34)
at swiper.js:136
at gl (react-dom.production.min.js:219)
at zs (react-dom.production.min.js:259)

I can't figure out where it comes from.
GitHub
Demo

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-10-20
@Aetae

Look where the error points. You take the specified "classList" and see where you use it in the project. You think that it could go wrong. What problems?
For example , here you have such crap

setTimeout(() => {
  inputRef.current.classList.remove("error");
}, 1000);

inputRef.currentexists only if there is popularMovies .
Accordingly, in order to reproduce the error, you need to poke getMoviesand make it so that it does not become faster than in a second popularMovies. How to do it - see for yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question