From 0f6cc9b775c08255eb9a3f9f917f42c2860507b4 Mon Sep 17 00:00:00 2001 From: Pavel Aksonov Date: Fri, 21 Sep 2018 16:54:34 +0200 Subject: [PATCH] allow null children for Router --- src/navigationStore.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/navigationStore.js b/src/navigationStore.js index a524fba57..33f316fb5 100644 --- a/src/navigationStore.js +++ b/src/navigationStore.js @@ -673,7 +673,7 @@ class NavigationStore { } // add all clones for (const child of children) { - if (child.props.clone) { + if (child && child.props.clone) { if (clones.indexOf(child) === -1) { clones.push(child); } @@ -682,6 +682,10 @@ class NavigationStore { let initialRouteName; let initialRouteParams; for (const child of children) { + // allow null/false child, useful for conditionals + if (!child) { + continue; + } const key = child.key || `key${(counter += 1)}`; const init = key === children[0].key; assert(reservedKeys.indexOf(key) === -1, `Scene name cannot be reserved word: ${child.key}`);