Answers for "get history data in 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
5

react history with search

this.props.history.push({
  pathname: '/template',
  search: '?query=abc',
  state: { detail: response.data }
})
Posted by: Guest on February-05-2021

Code answers related to "get history data in react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language