Potentially excess warning Discarded invalid param(s) "xxx" when navigating. #1946
-
I am getting the warning twice uppon navigating to the route that uses the param. This might seem like I forgot something, but interestingly this also happens:
Here is my set-up: // UserRoutes.ts
const BASE_URL = '/users';
const UserBaseRoute : RouteRecordRaw = {
path: BASE_URL,
name: 'Users',
component: () => import('@/app/users/UsersTable.view.vue'),
meta: {
title: 'users.title',
getParent: () => HomepageRoute
}
};
const UserCreateRoute : RouteRecordRaw = {
path: BASE_URL + '/create',
name: 'UserCreate',
component: () => import('@/app/users/UserCreateUpdate.view.vue'),
props: {
isEdit: false
},
meta: {
title: 'users.create.title',
getParent: () => UserBaseRoute
}
};
const UserUpdateRoute : RouteRecordRaw = {
path: BASE_URL + '/:userId(\\d+)',
name: 'UserUpdate',
component: () => import('@/app/users/UserCreateUpdate.view.vue'),
props: {
isEdit: true
},
meta: {
title: 'users.update.title',
getParent: () => UserBaseRoute
}
};
const userRoutes: Array<RouteRecordRaw> = [
UserBaseRoute,
UserCreateRoute,
UserUpdateRoute,
];
export default userRoutes; // Router.ts
const routes: RouteRecordRaw[] =[
// some other routes
...userRoutes,
// some other routes
];
const Router = createRouter({
history: createWebHistory(),
routes: routes
});
Router.beforeEach(to => {
if (!auth.authenticated() && to.name !== 'Login') {
return {name: 'Login'};
}
}); // navigation code
router.push({name: 'UserUpdate', params: {userId: user.id}}); //warning
// or
router.push('/users/' + user.id); //warning Am I something missing or did some anti-pattern? |
Beta Was this translation helpful? Give feedback.
Answered by
YummyHOF
Aug 3, 2023
Replies: 1 comment 2 replies
-
Do you have a boiled-down repro? This shouldn't happen with existing params |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I did some digging and found out that this is caused by creating RouterLink with excess params
When this link is created it shows the warning
Do you need full reproduction or this is enough to decide that the warning is justified?