State Management · Junior · Question 68 of 75
How do you read the :id part of the URL /users/:id in a React Router component?
- ✓Correct answer:
const { id } = useParams() - 2
useLoaderData().id - 3
window.location.id
Explanation
Params are always strings, so convert them if you need numbers. In loaders they arrive as params in the argument.