Answers for "use history mode for router in react class component"

6

react router dom push

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

this.props.history.location.push

props.history.push({  pathname: '/register', state: data_you_need_to_pass});
Posted by: Guest on November-18-2020
0

props history

{
  key: 'ac3df4', // not with HashHistory!
  pathname: '/somewhere',
  search: '?some=search-string',
  hash: '#howdy',
  state: {
    [userDefined]: true
  }
}
Posted by: Guest on December-02-2020

Code answers related to "use history mode for router in react class component"

Code answers related to "Javascript"

Browse Popular Code Answers by Language