From ef2821e503e81651f79fb20868d19df88c05c315 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Tue, 9 Apr 2019 10:13:09 +0200 Subject: [PATCH] Only animate transition when index changes --- packages/animated-switch/index.js | 8 +++++--- packages/animated-switch/package.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/animated-switch/index.js b/packages/animated-switch/index.js index c6875ebe..41e67389 100644 --- a/packages/animated-switch/index.js +++ b/packages/animated-switch/index.js @@ -12,9 +12,11 @@ const DEFAULT_TRANSITION = ( class SwitchView extends React.Component { containerRef = React.createRef(); - componentDidUpdate() { - this.containerRef.current && - this.containerRef.current.animateNextTransition(); + componentDidUpdate(prevProps) { + if (this.props.navigation.state.index !== prevProps.navigation.state.index) { + this.containerRef.current && + this.containerRef.current.animateNextTransition(); + } } render() { diff --git a/packages/animated-switch/package.json b/packages/animated-switch/package.json index dce89fc5..f14f216e 100644 --- a/packages/animated-switch/package.json +++ b/packages/animated-switch/package.json @@ -1,6 +1,6 @@ { "name": "react-navigation-animated-switch", - "version": "0.1.0", + "version": "0.1.1", "description": "", "main": "index.js", "author": "",