![]() |
VOOZH | about |
The useParams Hook allows you to access dynamic values from the URL in React Router. It helps render content based on route parameters like /user/:id.
Syntax
const { param1, param2, ... } = useParams();Note:
- Route parameters obtained using useParams() may sometimes be missing or invalid.
- It is recommended to validate them (e.g., check for undefined or correct format) before using.
- In such cases, you can show a fallback UI or redirect the user to a safe route.
Now let's understand this with the help of example:
Output