Skip to content

Instantly share code, notes, and snippets.

@WNortier
Last active November 5, 2022 13:34
Show Gist options
  • Save WNortier/bdab64de696071696cf3b9b0768824c3 to your computer and use it in GitHub Desktop.
Save WNortier/bdab64de696071696cf3b9b0768824c3 to your computer and use it in GitHub Desktop.
<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