Answers for "usehistory react 5"

8

useHistory

import { useNavigate } from 'react-router-dom';
const navigate = useNavigate();
navigate('/home');
Posted by: Guest on December-02-2021
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