State Management · Junior · Question 69 of 75
How does a React Router loader know which item to load?
export async function loader({ params }) {
return getUser(params.id);
}- ✓Correct answer: It receives
params(and therequest) as an argument - 2It calls
useParams()inside the loader - 3It reads a global variable set by the component
Explanation
Loaders run outside components, so hooks aren't available. request.url gives access to search params too.