Question · JavaScript and React course · Module 6: React Router
Passing state through navigation
How do you pass additional data (state) during navigation with useNavigate?
Answer options
- navigate('/target', { state: { key: 'value' } }) and read with useLocation().state
- navigate('/target?key=value') and read with useParams()
- navigate('/target', { data: { key: 'value' } }) and read with useNavigate().data
- You cannot pass additional data - only URL parameters
You can check the correct answer by solving this task in the CodeWorlds game.