mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-10 22:47:02 +08:00
Merge pull request #2 from itsjgf/master
Call animateNextTransition only when activeKey has changed
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user