From 8c62a92ae026226a685d5232db16b0f869d66faf Mon Sep 17 00:00:00 2001 From: Youssef Henna Date: Tue, 9 May 2023 20:02:19 +0300 Subject: [PATCH] Update how children are rendered to prevent state loss --- src/Swiper.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Swiper.js b/src/Swiper.js index 2758de2..7d358d8 100644 --- a/src/Swiper.js +++ b/src/Swiper.js @@ -7,8 +7,7 @@ import DefaultControls from './Controls'; const useNativeDriver = false; // because of RN #13377 class Swiper extends React.Component { - children = (() => React.Children.toArray(this.props.children))(); - count = (() => this.children.length)(); + count = (() => React.Children.toArray(this.props.children).length)(); startAutoplay() { const { timeout } = this.props; @@ -234,6 +233,7 @@ class Swiper extends React.Component { controlsEnabled, controlsProps, Controls = DefaultControls, + children, } = this.props; return ( @@ -257,7 +257,7 @@ class Swiper extends React.Component { ])} {...this._panResponder.panHandlers} > - {this.children.map((el, i) => ( + {children.map((el, i) => (