diff --git a/tests/Router-test.js b/tests/Router-test.js
index 97e1c718b8..95574a0679 100644
--- a/tests/Router-test.js
+++ b/tests/Router-test.js
@@ -832,6 +832,20 @@ describe('Router.run', function () {
});
});
+ it('does not break on falsy routes', function (done) {
+ var routes = [
+ ,
+ null,
+ ,
+ undefined
+ ];
+ Router.run(routes, '/foo', function (Handler, state) {
+ var html = React.renderToString();
+ expect(html).toMatch(/Foo/);
+ done();
+ });
+ });
+
it('matches nested routes', function (done) {
var routes = (
diff --git a/utils/createRoutesFromChildren.js b/utils/createRoutesFromChildren.js
index 9e50c85b90..5e74816c6a 100644
--- a/utils/createRoutesFromChildren.js
+++ b/utils/createRoutesFromChildren.js
@@ -154,8 +154,8 @@ function createRoutesFromChildren(children, parentRoute, namedRoutes) {
var routes = [];
React.Children.forEach(children, function (child) {
- // Exclude s and s.
- if (child = createRoute(child, parentRoute, namedRoutes))
+ // Exclude null values, s and s.
+ if (child && (child = createRoute(child, parentRoute, namedRoutes)))
routes.push(child);
});