[英]Navigation Issue while navigating using Android Hardware Back Press [react-native]
When I navigate to the first screen from the final screen of my App using hardware back press 当我使用硬件后退键从应用程序的最终屏幕导航到第一个屏幕时
It initially navigates to first screen and also bounces back to the final screen 最初会导航到第一个屏幕,然后反弹回最后一个屏幕
Also the animation that I have given in the first screen becomes a stuck and play like experience while navigating and this case is same for both types of navigation ie., 另外,我在第一个屏幕中给出的动画在导航时会变得停滞不前,像玩游戏一样 ,这种情况对于两种类型的导航都是相同的,即
-navigating with the back button in App and also while using hardware back press -在App中使用后退按钮进行导航,以及在使用硬件后按时
This is my final screen js file where I handle hardware back press: 这是我最后的屏幕js文件,我在其中处理硬件后按:
constructor(props) { super(props); this.handleBack = (() => { Actions.FirstScreen(); }); } componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBack); } componentWillUnmount() { BackHandler.removeEventListener('hardwareBackPress', this.handleBack); }
and this is the first screen's js file where I have the animation: 这是动画的第一个屏幕的js文件:
componentWillMount() { this.slide1 = new Animated.Value(0); this.slide2 = new Animated.Value(0); this.bnt1(); this.bnt2(); } bnt1() { Animated.timing( this.slide1, { delay: 100, toValue: w / 1.33, duration: 700, } ).start(); } bnt2() { Animated.timing( this.slide2, { delay: 700, toValue: -(w / 1.33), duration: 500, } ).start(); }
In your final screen js file
add this: 在您final screen js file
添加以下内容:
constructor(props) { super(props); this.handleBack = (() => { Actions.FirstScreen(); return true; }); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.