From d46f4912039997a6c1c9cda55f4f1826f84405d2 Mon Sep 17 00:00:00 2001 From: Christopher Reeve <work@creeve.me> Date: Tue, 10 Sep 2024 06:41:53 +0700 Subject: [PATCH] fix: missing import isRoute in the docs this PR fix a missing import and function calling in the docs route narrowing --- docs/advanced-concepts/route-narrowing.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/advanced-concepts/route-narrowing.md b/docs/advanced-concepts/route-narrowing.md index b359da4f..47f3e3be 100644 --- a/docs/advanced-concepts/route-narrowing.md +++ b/docs/advanced-concepts/route-narrowing.md @@ -49,7 +49,9 @@ if(router.route.name === 'user') { You can also use the `isRoute` type guard. You could write the same logic as above like this. ```ts -if(router.route, 'user', { exact: true }) { +import { isRoute } from '@kitbag/router' + +if(isRoute(router.route, 'user', { exact: true })) { router.route.name // "user" router.route.params // { userId: string } } @@ -58,6 +60,8 @@ if(router.route, 'user', { exact: true }) { The `isRoute` type guard offers more flexibility with the optional `exact` argument, which defaults to `false` and will return narrow to the target route or any of it's descendants. ```ts -if(router.route, 'user', { exact: false }) { +import { isRoute } from '@kitbag/router' + +if(isRoute(router.route, 'user', { exact: false })) { router.route.name // "user" | "user.profile" | "user.settings" router.route.params // { userId: string } | { userId: string, tab: string }