From 74ca163803f171745a3c53c5d19e1240ba49f83b Mon Sep 17 00:00:00 2001 From: yongxu Date: Thu, 3 Sep 2015 20:12:08 -0500 Subject: [PATCH] allow Route use plain route --- modules/Route.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/Route.js b/modules/Route.js index 7012ed5b95..5b394e7ae1 100644 --- a/modules/Route.js +++ b/modules/Route.js @@ -4,7 +4,7 @@ import invariant from 'invariant'; import { createRouteFromReactElement } from './RouteUtils'; import { component, components } from './PropTypes'; -var { string, bool, func } = React.PropTypes; +var { string, bool, func, object } = React.PropTypes; /** * A is used to declare which components are rendered to the page when @@ -33,6 +33,27 @@ var Route = React.createClass({ delete route.handler; } + if(route.plainRoute){ + if(route.childRoutes){ + if(route.plainRoute.childRoutes){ + warning( + false, + 'plainRoute.childRoutes will override route.children' + ); + } + + if(route.plainRoute.getChildRoutes){ + warning( + false, + 'route.children exist, plainRoute.getChildRoutes will be ignored' + ); + } + } + + route = {...route,...route.plainRoute}; + delete route.plainRoute; + } + return route; } @@ -44,7 +65,8 @@ var Route = React.createClass({ handler: component, // deprecated component, components, - getComponents: func + getComponents: func, + plainRoute: object }, render() {