[英]How to stop the Android Hardware Back Button from functioning in react-navigation for react-native?
[英]Navigation Issue while navigating using Android Hardware Back Press [react-native]
當我使用硬件后退鍵從應用程序的最終屏幕導航到第一個屏幕時
最初會導航到第一個屏幕,然后反彈回最后一個屏幕
另外,我在第一個屏幕中給出的動畫在導航時會變得停滯不前,像玩游戲一樣 ,這種情況對於兩種類型的導航都是相同的,即
-在App中使用后退按鈕進行導航,以及在使用硬件后按時
這是我最后的屏幕js文件,我在其中處理硬件后按:
constructor(props) { super(props); this.handleBack = (() => { Actions.FirstScreen(); }); } componentDidMount() { BackHandler.addEventListener('hardwareBackPress', this.handleBack); } componentWillUnmount() { BackHandler.removeEventListener('hardwareBackPress', this.handleBack); }
這是動畫的第一個屏幕的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(); }
在您final screen js file
添加以下內容:
constructor(props) { super(props); this.handleBack = (() => { Actions.FirstScreen(); return true; }); }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.