Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

props reactjs link

// 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 (...)
}
 
PREVIOUS NEXT
Tagged: #props #reactjs #link
ADD COMMENT
Topic
Name
9+9 =