Skip to content

Commit

Permalink
fix(react): fixed issut with Virtual Slides not working correctly
Browse files Browse the repository at this point in the history
Fixes #4162
  • Loading branch information
nolimits4web committed Jan 29, 2021
1 parent 5979102 commit c24f7ef
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/react/swiper.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,6 @@ const Swiper = forwardRef(
}
});

// watch for params change
useIsomorphicLayoutEffect(() => {
if (changedParams.length && swiperRef.current && !swiperRef.current.destroyed) {
updateSwiper(swiperRef.current, slides, passedParams, changedParams);
}
});

// update on virtual update
useIsomorphicLayoutEffect(() => {
updateOnVirtualData(swiperRef.current);
}, [virtualData]);

// mount swiper
useIsomorphicLayoutEffect(() => {
if (externalElRef) {
Expand Down Expand Up @@ -137,6 +125,18 @@ const Swiper = forwardRef(
};
}, []);

// watch for params change
useIsomorphicLayoutEffect(() => {
if (changedParams.length && swiperRef.current && !swiperRef.current.destroyed) {
updateSwiper(swiperRef.current, slides, passedParams, changedParams);
}
});

// update on virtual update
useIsomorphicLayoutEffect(() => {
updateOnVirtualData(swiperRef.current);
}, [virtualData]);

// bypass swiper instance to slides
function renderSlides() {
if (swiperParams.virtual) {
Expand Down

0 comments on commit c24f7ef

Please sign in to comment.