Merge pull request #2 from itsjgf/master

Call animateNextTransition only when activeKey has changed
This commit is contained in:
Brent Vatne
2019-04-10 16:51:21 +02:00
parent ef2821e503
commit e7df03ea35

View File

@@ -13,9 +13,13 @@ class SwitchView extends React.Component {
containerRef = React.createRef();
componentDidUpdate(prevProps) {
if (this.props.navigation.state.index !== prevProps.navigation.state.index) {
this.containerRef.current &&
this.containerRef.current.animateNextTransition();
const { state: prevState } = prevProps.navigation;
const prevActiveKey = prevState.routes[prevState.index].key;
const { state } = this.props.navigation;
const activeKey = state.routes[state.index].key;
if (activeKey !== prevActiveKey && this.containerRef.current) {
this.containerRef.current.animateNextTransition();
}
}