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);
}

Explanation

Loaders run outside components, so hooks aren't available. request.url gives access to search params too.

Further reading

Problem with a question

State Management · Junior · question 69

Test yourself

Take the State Management · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz