React-Native-ViewPager icon indicating copy to clipboard operation
React-Native-ViewPager copied to clipboard

getCurrentPageIndex() doesnt work?

Open KinanKazmi opened this issue 7 years ago • 1 comments

@jr-k Your fork doesnt work with getCurrentPageIndex() for me. It returns an undefined value. I looked into the code and accessed what that function was doing inside. It accesses the state of referenced viewpager component's state. Which only has width and height and no page index.

KinanKazmi avatar Oct 06 '17 10:10 KinanKazmi

It works if you tap on a tab to switch pages, but not for swiping. Not that useful.

Side note: not mentioned in the docs of this library is a method onPageScroll. This returns an object with params offset and position where position is the index you're looking for. You can use this to set a local state of index. Or if you give your <IndicatorViewPager> a ref. You can reference the current index using this.refs.YOURREFERENCE._currentIndex.

MattyK14 avatar Oct 10 '17 18:10 MattyK14