diff --git a/Example/Example.js b/Example/Example.js index 3ae27ab85..d7969ec64 100644 --- a/Example/Example.js +++ b/Example/Example.js @@ -22,13 +22,13 @@ class TabIcon extends React.Component { export default class Example extends React.Component { render() { return ( - + - + diff --git a/Example/iOS/AppDelegate.m b/Example/iOS/AppDelegate.m index 838f04b81..ccdce65db 100644 --- a/Example/iOS/AppDelegate.m +++ b/Example/iOS/AppDelegate.m @@ -47,7 +47,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation moduleName:@"Example" - initialProperties:nil + initialProperties:@{@"initialRoutes": @[@"launch", @"login"]} launchOptions:launchOptions]; self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; diff --git a/index.js b/index.js index 28af9ceca..2cd0358c9 100644 --- a/index.js +++ b/index.js @@ -456,7 +456,7 @@ class Router extends React.Component { super(props); this.routes = {}; this.schemas = {...props.schemas}; - this.initial = props.initial; + this.initial = this.props.initialRoutes || []; // Initial names array const self = this; React.Children.forEach(this.props.children, function (child, index) { @@ -468,8 +468,8 @@ class Router extends React.Component { React.Children.forEach(this.props.children, function (child, index) { const name = child.props.name; if (child.type.prototype.className() === "Route") { - if (child.props.initial || !self.initial) { - self.initial = name; + if (child.props.initial) { + self.initial.push(name); } // declare function with null navigator to avoid undefined Actions Actions.addAction(name, child.props, self.schemas, self) @@ -496,12 +496,12 @@ class Router extends React.Component { } render(){ - if (!this.state.initial){ + if (!this.state.initial.length){ console.error("No initial attribute!"); } - const initialRoute = this.routes[this.state.initial]; - if (!initialRoute) { - console.error("No initial route!"+JSON.stringify(this.routes)); + const initialRoutes = this.state.initial.map((name) => this.routes[name]); + if (!initialRoutes.length) { + console.error("No initial routes!"+JSON.stringify(this.routes)); } const Header = this.props.header; @@ -514,7 +514,7 @@ class Router extends React.Component { {header} new ExRoute(route, this.schemas))} style={styles.transparent} sceneStyle={{ paddingTop: 0 }} showNavigationBar={!this.props.hideNavBar}