Created
July 29, 2022 23:16
-
-
Save franciscojsc/1c7416362cd79b38187c78bd78d1590d to your computer and use it in GitHub Desktop.
React JS - using react-router-dom v6 - path param and query string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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