Last active
November 5, 2022 13:34
-
-
Save WNortier/bdab64de696071696cf3b9b0768824c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button onClick={ | |
() => { | |
navigate('/about', { state: { id: 1, name: 'sabaoon' }}) | |
} | |
}>Change to about page</button> | |
import { useLocation } from 'react-router-dom'; | |
import Button from 'react-bootstrap/Button'; | |
const UseLocationExample: React.FC = () => { | |
const location = useLocation(); | |
return ( | |
<> | |
<div>This is the about component for {location.state ? location.state.name : `No User`}</div> | |
<Button variant="primary" type="submit"> | |
Submit | |
</Button> | |
</> | |
) | |
} | |
export default UseLocationExample |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment