why we use usehistory in react code example
Example 1: usehistory example
import { useHistory } from 'react-router-dom';
function Home() {
const history = useHistory();
return ;
}
Example 2: useHistory react-router-dom
In react-router-dom version 6
useHistory() is replaced by useNavigate() ;
import {useNavigate} from 'react-router-dom';
const navigate = useNavigate();
navigate('/home')