У меня есть эта ошибка. Ожидается, что в конце стрелки будет возвращено значение.Я не уверен, как я могу предотвратить это.
Я пытаюсь остановить карусель Swiper, когда размер экрана ниже 1060px
import Swiper from 'swiper';
export default function () {
let articlesGalleryCarousel;
const doSomething = () => {
const enableSwiper = () => {
articlesGalleryCarousel = new Swiper('.js-swiper-container', {
loop: true,
slidesPerView: 'auto',
centeredSlides: true,
a11y: true,
keyboardControl: true,
grabCursor: true,
pagination: '.swiper-pagination',
paginationClickable: true,
navigation: {
nextEl: '.carousel-button--prev',
prevEl: '.carousel-button--next',
},
});
};
const breakpoint = window.matchMedia('(max-width:1060px)');
const breakpointChecker = () => {
if (breakpoint.matches === true) {
if (articlesGalleryCarousel !== undefined) articlesGalleryCarousel.destroy(true, true);
} else if (breakpoint.matches === false) {
return enableSwiper();
}
};
breakpoint.addListener(breakpointChecker);
breakpointChecker();
};
return doSomething;
}