bcgov / bcgov/entity

Pass route parameters to views as props rather than calling $route.query inside view component

Open
#15,708 1 comment 0 reactions 0 assignees View on GitHub
ENTITY - DO NOT USE techdebt
Dominant language
JavaScript
Stars
23
Forks
62
Avg merge
24m
Merged PRs (30d)
1

Description

## What is the problem?
Inside views we're using code as follows to get the route query parameters:

```javascript
get changeId (): number {
return +this.$route.query['change-id'] || 0
}
```

## What is the impact?
This is an atypical practice that makes it slightly more time consuming to get up to speed if you're a new developer on the team or if you are troubleshooting the application when it goes into maintenance.

## Proposed solution
It would be better to pass a prop from VueRouter from the routes file like this:

```javascript
{
path: '/change',
name: RouteNames.CHANGE,
component: Change,
props: route => ({
restorationId: route.query['change-id']
}),
meta: {
requiresAuth: true,
isStaffOnly: false,
filingType: FilingTypes.CHANGE_OF_REGISTRATION
}
},
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.