Skip to content

Commit

Permalink
feat(warn): more specific warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Dec 28, 2020
1 parent 8dad632 commit 2cd8d86
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/navigationGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function registerGuard(
*/
export function onBeforeRouteLeave(leaveGuard: NavigationGuard) {
if (__DEV__ && !getCurrentInstance()) {
warn('onBeforeRouteLeave must be called at the top of a setup function')
warn(
'getCurrentInstance() returned null. onBeforeRouteLeave() must be called at the top of a setup function'
)
return
}

Expand All @@ -63,7 +65,9 @@ export function onBeforeRouteLeave(leaveGuard: NavigationGuard) {

if (!activeRecord) {
__DEV__ &&
warn('onBeforeRouteLeave must be called at the top of a setup function')
warn(
'No active route record was found. Are you missing a <router-view> component?'
)
return
}

Expand All @@ -79,7 +83,9 @@ export function onBeforeRouteLeave(leaveGuard: NavigationGuard) {
*/
export function onBeforeRouteUpdate(updateGuard: NavigationGuard) {
if (__DEV__ && !getCurrentInstance()) {
warn('onBeforeRouteUpdate must be called at the top of a setup function')
warn(
'getCurrentInstance() returned null. onBeforeRouteUpdate() must be called at the top of a setup function'
)
return
}

Expand All @@ -90,7 +96,9 @@ export function onBeforeRouteUpdate(updateGuard: NavigationGuard) {

if (!activeRecord) {
__DEV__ &&
warn('onBeforeRouteUpdate must be called at the top of a setup function')
warn(
'No active route record was found. Are you missing a <router-view> component?'
)
return
}

Expand Down

0 comments on commit 2cd8d86

Please sign in to comment.