From eb9e874cf0013bf107985e00c95f33a07035420e Mon Sep 17 00:00:00 2001 From: Desyatnikov Grigorii Date: Wed, 24 Nov 2021 10:45:12 +0300 Subject: [PATCH] Test fix routing --- routing/Router.tsx | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/routing/Router.tsx b/routing/Router.tsx index ca85189..35cf544 100644 --- a/routing/Router.tsx +++ b/routing/Router.tsx @@ -19,6 +19,7 @@ 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 @@ -28,8 +29,9 @@ 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 = ( @@ -43,7 +45,15 @@ const renderRouteConfig = ( children.push(route) } else if (item.component && item.childRoutes) { - const routeConfig = renderRouteConfig(item.component, item.childRoutes, newContextPath) + 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) { @@ -56,7 +66,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 ( @@ -65,15 +75,13 @@ const renderRouteConfig = ( ) } - + console.log("mega end") return ( - - - - {children as JSX.TChildren[]} - - - + + + {children as JSX.TChildren[]} + + ) } @@ -87,8 +95,15 @@ 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) + return ( + + {renderRouteConfig(component, preparedRoutes, baseUrlPath)} + + ) + //renderRouteConfig(component, preparedRoutes, baseUrlPath) } export default Router