useQuery() with React Router Dom

brenonovelli

Breno Novelli

Posted on November 6, 2020

useQuery() with React Router Dom
import { useLocation } from 'react-router-dom';

const useQuery = () => new URLSearchParams(useLocation().search);

let query = useQuery();

console.log(query.get('myquery');
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
brenonovelli
Breno Novelli

Posted on November 6, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

useQuery() with React Router Dom
react useQuery() with React Router Dom

November 6, 2020