Skip to content

Commit

Permalink
fix: route tracking handle currentRoute to be null
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 6, 2023
1 parent 0dc4848 commit 7ca1fc9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/devtools/client/plugins/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default defineNuxtPlugin(() => {
})

router.afterEach(() => {
const path = router.currentRoute.value.path
if (path.includes('__'))
const path = router.currentRoute.value?.path
if (!path || path.includes('__'))
return
client.value?.hooks.callHook('devtools:navigate', path)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/setup/client-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function setupClientRPC() {
},
async navigateTo(path: string) {
client.value.open()
if (router.currentRoute.value.path !== path)
if (router.currentRoute.value?.path !== path)
router.push(path)
},
} satisfies ClientFunctions)
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/src/runtime/plugins/view/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export function useClientColorMode(): Ref<ColorScheme> {

function setupRouteTracking(timeline: TimelineMetrics, router: Router) {
// Add initial route event
if (router && timeline.options.enabled) {
if (timeline.options.enabled && router?.currentRoute?.value?.path) {
const start = timeline.events[0]?.start || Date.now()
timeline.events.unshift({
type: 'route',
Expand Down

0 comments on commit 7ca1fc9

Please sign in to comment.