Skip to content

Commit 2f9adf0

Browse files
committed
Throw when <DefaultRoute> or <NotFoundRoute> have children
Fixes #677
1 parent 49b5c8d commit 2f9adf0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

modules/createRoutesFromReactChildren.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ function createRoute(element, parentRoute, namedRoutes) {
104104
'You may not have more than one <NotFoundRoute> per <Route>'
105105
);
106106

107+
invariant(
108+
props.children == null,
109+
'<NotFoundRoute> must not have children'
110+
);
111+
107112
parentRoute.notFoundRoute = route;
108113

109114
return null;
@@ -121,6 +126,11 @@ function createRoute(element, parentRoute, namedRoutes) {
121126
'You may not have more than one <DefaultRoute> per <Route>'
122127
);
123128

129+
invariant(
130+
props.children == null,
131+
'<DefaultRoute> must not have children'
132+
);
133+
124134
parentRoute.defaultRoute = route;
125135

126136
return null;

0 commit comments

Comments
 (0)