Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example/Example.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class TabIcon extends React.Component {
export default class Example extends React.Component {
render() {
return (
<Router hideNavBar={true}>
<Router hideNavBar={true} initialRoutes={['launch', 'login']}>
<Schema name="modal" sceneConfig={Navigator.SceneConfigs.FloatFromBottom}/>
<Schema name="default" sceneConfig={Navigator.SceneConfigs.FloatFromRight}/>
<Schema name="withoutAnimation"/>
<Schema name="tab" type="switch" icon={TabIcon} />

<Route name="launch" component={Launch} initial={true} wrapRouter={true} title="Launch" hideNavBar={true}/>
<Route name="launch" component={Launch} wrapRouter={true} title="Launch" hideNavBar={true}/>
<Route name="register" component={Register} title="Register"/>
<Route name="home" component={Home} title="Replace" type="replace"/>
<Route name="login" schema="modal">
Expand Down
2 changes: 1 addition & 1 deletion Example/iOS/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -514,7 +514,7 @@ class Router extends React.Component {
<View style={styles.transparent}>
{header}
<ExNavigator ref="nav"
initialRoute={new ExRoute(initialRoute, this.schemas)}
initialRouteStack={initialRoutes.map((route) => new ExRoute(route, this.schemas))}
style={styles.transparent}
sceneStyle={{ paddingTop: 0 }}
showNavigationBar={!this.props.hideNavBar}
Expand Down