Answers for "react get history"

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
0

history react router

history.push(
			`/product?make=${car_make_id}&model=${car_model_id}&year=${car_generation_id}&series=${car_serie_id}&engine=${car_trim_id}&variant=${car_equipment_id}`
		);
Posted by: Guest on March-26-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language