rilyu / teaset

A UI library for react native, provides 20+ pure JS(ES6) components, focusing on content display and action control.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SegmentedView active title doesn't not match with the active index

eugeneli71 opened this issue · comments

When using SegmentedView with type='carousel' and navigating using swipe gesture, the active title index doesn't change correctly. As the picture shown, The current active index is 2 ,and the active bar displayed under "Three", but the active text still on "Two". This only happen when using wipe gesture.
Simulator Screen Shot - iPhone 11 - 2020-07-07 at 20 35 19

componentDidUpdate(prevProps) {
if (prevProps.activeIndex != this.props.activeIndex && this.refs.carousel) {
this.refs.carousel.scrollToPage(this.props.activeIndex);
}
}
ActiveIndex need to be updated when scrolling .
this issue can be fixed by adding this.setState({activeIndex:this.props.activeIndex}) after this.refs.carousel.scrollToPage(this.props.activeIndex);