From 5128f3cbb74ffdf2ce6b8102b6212c2887bf5751 Mon Sep 17 00:00:00 2001 From: AbdeenM Date: Tue, 13 Oct 2020 22:21:30 +0200 Subject: [PATCH] Added scroll view throttle, switched to componentDidUpdate --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index a47d574..8cacc9b 100644 --- a/index.js +++ b/index.js @@ -110,7 +110,7 @@ export default class Carousel extends Component { this._clearTimer(); } - componentWillReceiveProps({ children }) { + componentDidUpdate({ children }) { if (!isEqual(this.props.children, children)) { const { currentPage } = this.state; this._clearTimer(); @@ -145,7 +145,7 @@ export default class Carousel extends Component { pages.push(children[0]); } else { pages.push( - You are supposed to add children inside Carousel + You are supposed to add children inside Carousel ); } return pages.map((page, i) => ( @@ -408,6 +408,7 @@ export default class Carousel extends Component { onScrollBeginDrag={this._onScrollBegin} onMomentumScrollEnd={this._onScrollEnd} onScroll={this._onScroll} + scrollEventThrottle={20} alwaysBounceHorizontal={false} alwaysBounceVertical={false} contentInset={{ top: 0 }}