React-Native-ViewPager
React-Native-ViewPager copied to clipboard
getCurrentPageIndex() doesnt work?
@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.
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
.