Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

reactjs router link props

// 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 :: js trigger mouseover 
Javascript :: how to find length of string in javascript without using length method 
Javascript :: javascript for loops in vs of 
Javascript :: javascript remove first space in string 
Javascript :: classlist remove all classes 
Javascript :: redirecting to a different route if user is logged in 
Javascript :: transition event listener does not work 
Javascript :: get file name nodejs 
Javascript :: arry suffle javascript 
Javascript :: react media query hook 
Javascript :: reload datatable ajax 
Javascript :: play music from file js 
Javascript :: credit card mask js 
Javascript :: array filter falsy values 
Javascript :: js get childrens 
Javascript :: javascript compare two objects 
Javascript :: wait one second in javascript using async wait 
Javascript :: loopback upsert with where 
Javascript :: lodash find object in array 
Javascript :: Exceeded timeout of 5000 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." 
Javascript :: flutter convert json string to json 
Javascript :: ReferenceError: http Server is not defined 
Javascript :: javascript un hiden element 
Javascript :: imagebackground in react native 
Javascript :: ajax delete laravel 
Javascript :: js check if function exists 
Javascript :: hide html element with javascript 
Javascript :: javascript word count 
Javascript :: print odd numbers in an array in javascript 
Javascript :: firebase react router page not found on page refresh 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =