react router link onclick code example
Example 1: programmatically redirect react router
import { useHistory } from "react-router-dom";
function HomeButton() {
const history = useHistory();
function handleClick() {
history.push("/home");
}
return (
<button type="button" onClick={handleClick}>
Go home
</button>
);
}
Example 2: router link @click
<router-link :to="{name: 'landing'}" tag="li" exact v-on:click.native="close()">Home</router-link>
<!-- Use the .native modifier -->