From bc7fa3d6f1c1e8a386acb10c2f3beb9a237f7e1b Mon Sep 17 00:00:00 2001 From: Robby6Strings Date: Sat, 24 Feb 2024 21:03:48 +1300 Subject: [PATCH] simplify router logic --- packages/lib/src/router.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/lib/src/router.ts b/packages/lib/src/router.ts index 17526729..5bc1c6aa 100644 --- a/packages/lib/src/router.ts +++ b/packages/lib/src/router.ts @@ -38,22 +38,22 @@ function Router(props: RouterProps) { let fallbackRoute: RouteComponent | undefined for (const child of props.children ?? []) { - if (isRoute(child)) { - if (isFallbackRoute(child)) { - fallbackRoute = child - continue - } - const routeSegments = ((props.basePath || "") + child.props.path).split( - "/" - ) - const params = matchPath(routeSegments, pathSegments) - if (params) { - return fragment({ - children: [createElement(child.props.element, { params, query })], - }) - } + if (!isRoute(child)) continue + + if (isFallbackRoute(child)) { + fallbackRoute = child + continue + } + + const routeSegments = ((props.basePath || "") + child.props.path).split("/") + const params = matchPath(routeSegments, pathSegments) + if (params) { + return fragment({ + children: [createElement(child.props.element, { params, query })], + }) } } + if (fallbackRoute) { return fragment({ children: [