Answers for "react router link onclick"

2

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>
  );
}
Posted by: Guest on February-15-2020
1

router link @click

<router-link :to="{name: 'landing'}" tag="li" exact v-on:click.native="close()">Home</router-link>
<!-- Use the .native modifier -->
Posted by: Guest on March-27-2020

Browse Popular Code Answers by Language