Skip to content

Instantly share code, notes, and snippets.

@franciscojsc
Created July 29, 2022 23:16
Show Gist options
  • Save franciscojsc/1c7416362cd79b38187c78bd78d1590d to your computer and use it in GitHub Desktop.
Save franciscojsc/1c7416362cd79b38187c78bd78d1590d to your computer and use it in GitHub Desktop.
React JS - using react-router-dom v6 - path param and query string
import { useParams, useSearchParams } from 'react-router-dom';
export function Home() {
// path param
const { id } = useParams();
console.log(id);
// query string
const [params, setParams] = useSearchParams();
console.log(params.get('id'));
return (
<div>
<h1>FRANCISCO CHAVES</h1>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment