How to access params IF app is at the route outside of Outlet? #955
-
Wondered if I could get some advice on how to set this app up. So in my RootRoute I have the following setup.
The NavBar is as follows. When the search is submitted, the navigation to the search page works great with the params being set correctly. I want to autofill the search bar to get the search query from the params, but the page won't always be on "/search".
If I load the page on any other route, the error below appears
Is there a best practice way of accessing params IF the route is "/search", without throwing an error? For reference the search route is as below
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I answered the question myself, but I will leave the answer below: In my navigation bar, I now do the following:
The "router.state.location.search" will be a partial type of all of the different route's params combined; pretty nice 👍 |
Beta Was this translation helpful? Give feedback.
I answered the question myself, but I will leave the answer below:
In my navigation bar, I now do the following:
The "router.state.location.search" will be a partial type of all of the different route's params combined; pretty nice 👍