react-navigation.github.io icon indicating copy to clipboard operation
react-navigation.github.io copied to clipboard

[Question]Adding animation to screens in bottom nav when route changed

Open BJSam opened this issue 4 years ago • 0 comments

I have managed to animate screen in react native when bottom nav changes route.

Here what I am doing I am using react-native-animatable import * as Animatable from 'react-native-animatable';

constructor(props: any) {
        super(props)
        this.state = {
         
         dummyKey:4564654
            
        };
}

componentDidMount(){
	this.props.navigation.addListener('focus', (e: any) => {   
       if(e){          
       
         this.setState({dummyKey:Math.random()})
       }
     })
}
render(){
 <Animatable.View key={this.state.dummyKey} animation={'bounceIn'} >
     //View to animate when loaded
    </Animatable.View>              
}

is this the correct way?

BJSam avatar Mar 10 '21 17:03 BJSam