In react-router-dom version 6
useHistory() is replaced by useNavigate() ;
import {useNavigate} from 'react-router-dom';
const navigate = useNavigate();
navigate('/home')
Example 2: uselocation hook
import { useHistory } from 'react-router-dom';
function Home() {
const history = useHistory();
return ;
}
Example 3: how to get state value from history react