Skip to content

Instantly share code, notes, and snippets.

@munierujp
Last active August 9, 2022 07:34
Show Gist options
  • Save munierujp/fd64d9304ffa95353fc48412a43f7a89 to your computer and use it in GitHub Desktop.
Save munierujp/fd64d9304ffa95353fc48412a43f7a89 to your computer and use it in GitHub Desktop.
import { useMemo } from 'react'
import { useLocation } from 'react-router-dom'
/**
* @see https://v5.reactrouter.com/web/example/query-parameters
*/
export const useQueryParams = (): URLSearchParams => {
const { search } = useLocation()
return useMemo(() => new URLSearchParams(search), [search])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment