Answers for "usehistory hook in react?"

14

usehistory example

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
0

useHistory() hook

// useHistory() has been changed in v6, so instead use useNavigate()

check out the source link
Posted by: Guest on January-25-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language