Answers for "get history from router react"

6

in react js how to access history in component

import { useHistory } from "react-router-dom";

function HomeButton() {
  let history = useHistory();

  function handleClick() {
    history.push("/home");
  }

  return (
    <Button type="button" onClick={handleClick}>
      Go home
    </Button>
  );
}
Posted by: Guest on May-11-2020
1

use history react router dom

import { useHistory } from "react-router-dom";
Posted by: Guest on August-13-2021

Code answers related to "get history from router react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language