Opinion: Processing $route.params in components

Hi Everyone,

I have a general Vue application/component design question. I have a page on my site that gets called when a user clicks a link from an external source. Similar to getting an email with a link such as “Click this link to validate your new user account.”

All that is fine. My question is, should the parent page process $route.params and pass them into a component as props for processing, or is it alright component design to process $route.params directly from within the component?

Currently, I’ve been capturing and processing the $route.params directly from within the component to keep the parent page code cleaner and smaller.

Preferences or thoughts?

~ Brad

Hi. I think it is a good design. Each component in a route should handle it’s own parameters. Otherwise you need to pass the same data in another way and it would only make your logic more complicated.

Hi johandalabacka, thanks for the reply.

The other option would be to capture the $route.params in the parent page and pass them into the child component as props. But in this case, the parent page would most likely be responsible for validating that the proper params exist etc., which again of course adds more code and bloat to the parent page.

So, from they way I’m approaching the page / component design, I would have to agree with you.

~ Brad