Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

props to react router 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 (...)
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: disemvowel trolls codewars javascript 
Javascript :: javascript open new window and pass data 
Javascript :: li key attribute 
Javascript :: javascript object array merge 
Javascript :: material ui disable textfield 
Javascript :: Error: [ProtectedRoute] is not a <Route component 
Javascript :: how to pass props in gatsby link using styledcomponent 
Javascript :: js when key is pressed 
Javascript :: clear elements of table javascript 
Javascript :: useMediaQuery react hook 
Javascript :: jquery page finished loading 
Javascript :: play audio in javascript 
Javascript :: javascript queryselector starts with 
Javascript :: username validation formik react yup 
Javascript :: hide and show modal jquery 
Javascript :: pad js 
Javascript :: (node:2736) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead. 
Javascript :: polyfill for apply 
Javascript :: nock CORS error 
Javascript :: js indexof nested array 
Javascript :: js create timestamp with 10 digits 
Javascript :: focus js 
Javascript :: javascript get second last element in array 
Javascript :: how to get back image and front text in react native 
Javascript :: how to copy text in js 
Javascript :: atob nodejs 
Javascript :: html javascript call function after pressing enter 
Javascript :: javascript character count 
Javascript :: how to check if a message has an attachment discord js 
Javascript :: fs.unlink 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =