Quantcast
Channel: Programmatically navigate using react router V4 - Stack Overflow
Viewing all articles
Browse latest Browse all 18

Answer by user14433996 for Programmatically navigate using react router V4

$
0
0

You can navigate conditionally by this way

import { useHistory } from "react-router-dom";function HomeButton() {  const history = useHistory();  function handleClick() {    history.push("/path/some/where");  }  return (<button type="button" onClick={handleClick}>      Go home</button>  );}

Viewing all articles
Browse latest Browse all 18

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>