Replies: 1 comment
-
You could define a What I wouldn't do is get any sort of state from useRoute in your navbar if it's a component you use everywhere, instead let the page either pass some props or a slot to the navbar, or use a pinia store. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm struggling a bit with how to handle typed params in child routes
Say I have these pages
I then create a navbar component that displays just slightly differently when used inside company pages based on the companyId param.
How would I go about getting the correct types for the params?
Without typed params I could just do a simple undefined check
But with typed params I'm not allowed to do the undefined check because of the never record type.
My only other idea would be to send in the company id to the navbar with a prop instead but that still leaves it open to forgetfulness since the component is still valid without a company id
Would it be possible to extend the params to allow for name wildcards or something similar to simplify this?
I'm not the best at typescript so I might just be missing something obvious, but then please enlighten me.
I'm also using Nuxt if that changes anything.
Beta Was this translation helpful? Give feedback.
All reactions