// Component 1 - Link with state
<Link to="/onboarding/profile" state={{ message: "hello" }}>Next Step</Link>
// Component 2 - Get the state
import { useLocation } from 'react-router-dom'
function Profile () {
const location = useLocation()
const { message } = location.state // "useLocation" to get the state
console.log(message) // Console Output: hello
return (...)
}
<Link
to='/onboarding/profile'
state={{ from: 'occupation' }}
>
Next Step
</Link>