Put in order · JavaScript and React course · Module 6: React Router
Passing data through location state
Arrange the steps for passing and reading data between routes:
Items to put in order
- Prepare the data to pass in a state object
- Read the passed data from location.state
- Use navigate('/path', { state: { data } }) or <Link state={...}>
- In the target component, call useLocation()
- React Router navigates to the new route with hidden state
You can check the correct answer by solving this task in the CodeWorlds game.