mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
feat(nuxt): warn in dev when useRoute
is used in middleware (#20050)
This commit is contained in:
parent
79ad5ac9bc
commit
61699f864e
@ -17,6 +17,9 @@ export const useRouter = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useRoute = (): RouteLocationNormalizedLoaded => {
|
export const useRoute = (): RouteLocationNormalizedLoaded => {
|
||||||
|
if (process.dev && isProcessingMiddleware()) {
|
||||||
|
console.warn('[nuxt] Calling `useRoute` within middleware may lead to misleading results. Instead, use the (to, from) arguments passed to the middleware to access the new and old routes.')
|
||||||
|
}
|
||||||
if (getCurrentInstance()) {
|
if (getCurrentInstance()) {
|
||||||
return inject('_route', useNuxtApp()._route)
|
return inject('_route', useNuxtApp()._route)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user