Skip to content

Instantly share code, notes, and snippets.

@junhoyeo
Created December 7, 2021 10:41
Show Gist options
  • Save junhoyeo/569058a7b42d3ba5763bd8b3fd7b85f0 to your computer and use it in GitHub Desktop.
Save junhoyeo/569058a7b42d3ba5763bd8b3fd7b85f0 to your computer and use it in GitHub Desktop.
Remove query parameter from current route
export const removeQueryParameter = (name: string) => {
const params = new URLSearchParams(location.search)
params.delete(name)
history.replaceState(null, '', '?' + params + location.hash)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment