Only animate transition when index changes

This commit is contained in:
Brent Vatne
2019-04-09 10:13:09 +02:00
parent 69e4da0f25
commit ef2821e503
2 changed files with 6 additions and 4 deletions

View File

@@ -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() {

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation-animated-switch",
"version": "0.1.0",
"version": "0.1.1",
"description": "",
"main": "index.js",
"author": "",