Answers for "usehistory class react"

2

equivalent of useHistory in react

import { useHistory } from "react-router-dom"; // DEPRECATED
// It is now
import { useNavigate } from "react-router-dom"; // As at March 3, 2022
Posted by: Guest on March-03-2022
14

useHistory()

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

function Home() {
  const history = useHistory();
  return <button onClick={() => history.push('/profile')}>Profile</button>;
}
Posted by: Guest on May-04-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language