Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Alen Abraham
Added: May 18, 2020 2:48 PM
Modified: May 18, 2020 2:58 PM
Views: 129
  1. import { createSwitchNavigator } from 'react-navigation';
  2. // create switch navigation with authentication flow and main app
  3. const SwitchNavigator = createSwitchNavigator(
  4.   {
  5.     Login: AuthNavigator,
  6.     App: AppNavigator
  7.   },
  8.   {
  9.     initialRouteName: 'Login'
  10.   }
  11. );
  12. const App = () => (
  13.   <SwitchNavigator />
  14. );
  15. export default App;
  16.  
  17.  
  18. //TO move to specific navigation -- use
  19.  
  20. this.props.navigation.push('Profile');
  21.  
  22. this.props.navigation.pop();
  23.  
  24. this.props.navigation.replace('Home');
  25.  
  26. //same as push, but if already present, it wont add new snippet
  27. this.props.navigation.navigate('Profile')

1 comment

Alen Abraham 5 months ago
Use this snippet to implement routing and navigation between screens in react native

Write a comment