In react-router-dom version 6
useHistory() is replaced by useNavigate() ;
import {useNavigate} from 'react-router-dom';
const navigate = useNavigate();
navigate('/home')
// useHistory() has been changed in v6, so instead use useNavigate()
check out the source link