Put in order · JavaScript and React course · Module 6: React Router
Programmatic navigation in React Router
Arrange the steps for programmatic navigation using useNavigate:
Items to put in order
- Call navigate('/target-path') in the event handler
- The user performs an action (e.g., clicks a button)
- Import useNavigate from react-router-dom
- Call const navigate = useNavigate() in the component
- React Router updates the URL and renders the new component
You can check the correct answer by solving this task in the CodeWorlds game.