From 0a76652c5c83a84f1fe55cba27deb9f45d1d3986 Mon Sep 17 00:00:00 2001 From: Tuan Luong Date: Wed, 27 May 2020 07:32:48 +0700 Subject: [PATCH 1/2] get carousel ref --- src/carousel/Carousel.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/carousel/Carousel.js b/src/carousel/Carousel.js index 83638dee4..38c4c9df8 100644 --- a/src/carousel/Carousel.js +++ b/src/carousel/Carousel.js @@ -481,6 +481,10 @@ export default class Carousel extends Component { } _getWrappedRef () { + if (this._carouselRef && ( + (this._needsScrollView() && this._carouselRef.scrollTo) || + (!this._needsScrollView() && this._carouselRef.scrollToOffset) + )) { // https://github.com/facebook/react-native/issues/10635 // https://stackoverflow.com/a/48786374/8412141 return this._carouselRef && this._carouselRef.getNode && this._carouselRef.getNode(); From 4bcbe056352ed0917aa9032c3e1c84bbf24dba98 Mon Sep 17 00:00:00 2001 From: Tuan Luong Date: Wed, 27 May 2020 12:14:42 +0700 Subject: [PATCH 2/2] Update Carousel.js --- src/carousel/Carousel.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/carousel/Carousel.js b/src/carousel/Carousel.js index 38c4c9df8..dae71a3da 100644 --- a/src/carousel/Carousel.js +++ b/src/carousel/Carousel.js @@ -482,9 +482,11 @@ export default class Carousel extends Component { _getWrappedRef () { if (this._carouselRef && ( - (this._needsScrollView() && this._carouselRef.scrollTo) || - (!this._needsScrollView() && this._carouselRef.scrollToOffset) + (this._needsScrollView() && this._carouselRef.scrollTo) || + (!this._needsScrollView() && this._carouselRef.scrollToOffset) )) { + return this._carouselRef; + } // https://github.com/facebook/react-native/issues/10635 // https://stackoverflow.com/a/48786374/8412141 return this._carouselRef && this._carouselRef.getNode && this._carouselRef.getNode();