2017-05-31 43 views
0

我在我的應用程序中使用了React-Navigation,並且找不到辦法做幾件事。 首先,我想改變過渡動畫,但我無法找到這樣做,如果你們能幫助我,我會很高興。反應導航 - 動畫,替換屏幕和標籤

其次,我有一個登錄屏幕,登錄時,用戶被移動到主屏幕,在主屏幕上我得到一個後退按鈕,所以我可以再次登錄(我不想)我使用此代碼嘗試:

handlePress(navigate){ 
    firebaseRef.auth().signInWithEmailAndPassword(this.state.email, this.state.password).then(function(firebaseUser){ 
     //Success, move to homepage. 
     navigate.replace("Home"); 
    }).catch(function(error){ 
     //Failed to log in, print error. 
    }); 
} 

,但它不會工作,什麼都不會發生(它不會導航到家庭),只有當我使用navigate("Home");它定位到家裏。

這是導航(內部渲染):

const { navigate } = this.props.navigation; 

第三,我有幾個屏幕(登錄,註冊,家庭和朋友),這是我的StackNavigator:

const Stylelist = StackNavigator({ 
    Login:{ 
    screen: LoginScreen, 
    navigationOptions: ({navigation}) =>({ 
     header: null, 
    }), 
    }, 
    Register:{ 
     screen: RegisterScreen, 
     navigationOptions: ({navigation}) =>({ 
     header: null, 
     }), 
    }, 
    Home:{ 
    screen: HomeScreen, 
    navigationOptions: ({navigation}) =>({ 
     header: "float", 
     title: "Home", 
    }), 
    }, 
}); 

我想要的主屏幕也成爲TabNavigator的一部分(與朋友屏幕。) 我搜索了網頁,但無法找到如何做到這一點。 你們能幫我嗎?給我提供信息來源/例子。 在此先感謝!

回答

3

這應該刪除後退按鈕看到doc

import { NavigationActions } from 'react-navigation'; 


    handlePress(){ 
     firebaseRef.auth().signInWithEmailAndPassword(this.state.email, this.state.password).then(function(firebaseUser){ 
      //Success, move to homepage. 
      const resetAction = NavigationActions.reset({ 
      index: 0, 
      actions: [ 
      NavigationActions.navigate({ routeName: 'Home'}) 
      ] 
     }) 
     this.props.navigation.dispatch.(resetAction); 
     }).catch(function(error){ 
      //Failed to log in, print error. 
     }); 
     } 
+0

謝謝你,偉大的工作。 –

+0

@JohnDoah,你的歡迎 –