Skip to content

Commit

Permalink
fix(ui): view-pager - external state control
Browse files Browse the repository at this point in the history
  • Loading branch information
artyorsh authored Jul 29, 2019
1 parent fced535 commit e5285d7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/framework/ui/viewPager/viewPager.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ export class ViewPager extends React.Component<ViewPagerProps> implements PanRes
this.contentOffset.addListener(this.onContentOffsetAnimationStateChanged);
}

public componentDidUpdate(prevProps: ViewPagerProps) {
if (prevProps.selectedIndex !== this.props.selectedIndex) {
const index: number = this.props.selectedIndex;
this.scrollToIndex({ index, animated: true });
}
}

public componentWillUnmount() {
this.contentOffset.removeAllListeners();
}
Expand Down

0 comments on commit e5285d7

Please sign in to comment.