Skip to content

Commit 1f3fd5c

Browse files
committed
Move Navigator into a dedicated folder
1 parent a7d669d commit 1f3fd5c

File tree

3 files changed

+33
-28
lines changed

3 files changed

+33
-28
lines changed

App/Containers/Root/RootScreen.js

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,12 @@
11
import React, { Component } from 'react'
2-
import { createStackNavigator, createAppContainer } from 'react-navigation'
32
import NavigationService from 'App/Services/NavigationService'
3+
import AppNavigator from 'App/Navigators/AppNavigator'
44
import { View } from 'react-native'
55
import styles from './RootScreenStyle'
6-
import ExampleScreen from 'App/Containers/Example/ExampleScreen'
7-
import SplashScreen from 'App/Containers/SplashScreen/SplashScreen'
86
import { connect } from 'react-redux'
97
import StartupActions from 'App/Stores/Startup/Actions'
108
import { PropTypes } from 'prop-types'
119

12-
/**
13-
* The root screen contains the application's navigation.
14-
*
15-
* @see https://reactnavigation.org/docs/en/hello-react-navigation.html#creating-a-stack-navigator
16-
*/
17-
const AppNav = createStackNavigator(
18-
{
19-
// Create the application routes here (the key is the route name, the value is the target screen)
20-
// See https://reactnavigation.org/docs/en/stack-navigator.html#routeconfigs
21-
SplashScreen: SplashScreen,
22-
// The main application screen is our "ExampleScreen". Feel free to replace it with your
23-
// own screen and remove the example.
24-
MainScreen: ExampleScreen,
25-
},
26-
{
27-
// By default the application will show the splash screen
28-
initialRouteName: 'SplashScreen',
29-
// See https://reactnavigation.org/docs/en/stack-navigator.html#stacknavigatorconfig
30-
headerMode: 'none',
31-
}
32-
)
33-
34-
const App = createAppContainer(AppNav)
35-
3610
class RootScreen extends Component {
3711
componentDidMount() {
3812
// Run the startup saga when the application is starting
@@ -42,7 +16,7 @@ class RootScreen extends Component {
4216
render() {
4317
return (
4418
<View style={styles.container}>
45-
<App
19+
<AppNavigator
4620
// Initialize the NavigationService (see https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html)
4721
ref={(navigatorRef) => {
4822
NavigationService.setTopLevelNavigator(navigatorRef)

App/Navigators/AppNavigator.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { createAppContainer, createStackNavigator } from 'react-navigation'
2+
3+
import ExampleScreen from 'App/Containers/Example/ExampleScreen'
4+
import SplashScreen from 'App/Containers/SplashScreen/SplashScreen'
5+
6+
/**
7+
* The root screen contains the application's navigation.
8+
*
9+
* @see https://reactnavigation.org/docs/en/hello-react-navigation.html#creating-a-stack-navigator
10+
*/
11+
const StackNavigator = createStackNavigator(
12+
{
13+
// Create the application routes here (the key is the route name, the value is the target screen)
14+
// See https://reactnavigation.org/docs/en/stack-navigator.html#routeconfigs
15+
SplashScreen: SplashScreen,
16+
// The main application screen is our "ExampleScreen". Feel free to replace it with your
17+
// own screen and remove the example.
18+
MainScreen: ExampleScreen,
19+
},
20+
{
21+
// By default the application will show the splash screen
22+
initialRouteName: 'SplashScreen',
23+
// See https://reactnavigation.org/docs/en/stack-navigator.html#stacknavigatorconfig
24+
headerMode: 'none',
25+
}
26+
)
27+
28+
export default createAppContainer(StackNavigator)

App/Navigators/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This directory contains your main Navigator (AppNavigator.js)
2+
3+
You can add nested navigators on this folder if you need it.

0 commit comments

Comments
 (0)