From 0fe010ccdc69626222d67a0bc52c39329afdeef6 Mon Sep 17 00:00:00 2001 From: Desyatnikov Grigorii Date: Mon, 29 Nov 2021 12:13:09 +0300 Subject: [PATCH] Fix routing for childRoutes --- routing/Router.tsx | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/routing/Router.tsx b/routing/Router.tsx index bfa64cc..4d6c20c 100644 --- a/routing/Router.tsx +++ b/routing/Router.tsx @@ -19,7 +19,6 @@ const renderRouteConfig = ( ): JSX.Element => { // Resolve route config object in React Router v3. const children: React.ReactNode[] = [] - console.log("start") const renderRoute = (item: RouteDefinition, routeContextPath: string) => { let newContextPath: string @@ -29,9 +28,8 @@ const renderRouteConfig = ( } else { newContextPath = `${routeContextPath}/${item.path}` } - //newContextPath = `${routeContextPath}/${item.path}` + newContextPath = newContextPath.replace(/\/+/g, '/') - console.log(newContextPath, item.name) if (item.redirect) { const route = ( @@ -45,15 +43,7 @@ const renderRouteConfig = ( children.push(route) } else if (item.component && item.childRoutes) { - console.log(item.name) const routeConfig = renderRouteConfig(item.component, item.childRoutes, newContextPath) - // ( - // - // {renderRouteConfig(item.component, item.childRoutes, newContextPath)} - // - // ) children.push(routeConfig) } else if (item.component) { @@ -66,7 +56,7 @@ const renderRouteConfig = ( } routes.forEach(item => renderRoute(item, contextPath)) - console.log("end", children.length) + // Use Switch as the default container by default if (!Container) { return ( @@ -75,7 +65,7 @@ const renderRouteConfig = ( ) } - console.log("mega end") + return ( @@ -95,15 +85,12 @@ const Router: React.FC = (props: Props) => { const { routeConfig, component, baseUrlPath } = props const preparedRoutes = prepareRoutes(routeConfig) - console.log(preparedRoutes) - //console.log("React",renderRouteConfig(component, preparedRoutes, baseUrlPath)) return ( {renderRouteConfig(component, preparedRoutes, baseUrlPath)} ) - //renderRouteConfig(component, preparedRoutes, baseUrlPath) } export default Router