Removing extra params from routes
See original GitHub issueSorry to use GH as support board but I’ve been dealing with this problems for hours now.
Lets say I have something like:
<Link
route="my-route"
params={{ slug: item.slug, id: item.id }}
passHref
>
...
.add('my-route', '/my-route/:slug/', 'my-route/XYZ')
What is the correct way to remove item.id
from on the final route? On my case it will render something like http://0.0.0.0:4000/my-route/nice-slug/?id=26
I dont want to display ?id=26
Any ideas?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Angular 5 remove query param - Stack Overflow
You can remove a query parameter by using the merge option of queryParamsHandling and passing in null for any params you wish to...
Read more >Provide a way to remove specific parameter from query string
When you remove it then the corresponding parameter should be removed from the query string. Currently you can add new query parameter by:....
Read more >How to remove query params using React router | bobbyhadz
To remove query params using React router, use the `useSearchParams` hook to get the current location's search params. Use the `delete()` method to...
Read more >How to remove parameters from url - Laracasts
A regular query string doesn't need any extra parameters in the route if its a get route. Just pass in the URL. Then...
Read more >Router options - router5
There are two ways to deal with not found routes: the first one is to configure a defaultRoute (and defaultParams ), the second...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same question
Glad to hear you got it working. Another way would be to keep the id in the url with a route like
/my-route/:id/:slug
. Depending on the database system and indexing, it can be faster to lookup by id.