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.

Revisions

  1. munierujp revised this gist Aug 9, 2022. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions useQueryParams.ts
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    import { useMemo } from 'react';
    import { useLocation } from 'react-router-dom';
    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]);
    };
    const { search } = useLocation()
    return useMemo(() => new URLSearchParams(search), [search])
    }
  2. munierujp created this gist Aug 9, 2022.
    10 changes: 10 additions & 0 deletions useQueryParams.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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]);
    };