I am using React router dom v6, and the “useHistory” method is not available in the React router v6 version.
Please suggest me how I can implment below code with React Router com v6 version
history.listen(onParentNavigate);
export default () => {
const ref = useRef(null);
const location = useLocation();
const navigate = useNavigate();
const history = useHistory();
useEffect(() => {
const { onParentNavigate } = mount(ref.current, {
onNavigate: ({ location }: any) => {
navigate(location.pathname);
},
});
// PLEASE SUGGEST ME HOW I CAN IMPLEMENT THIS WITH REACT ROUTER V6 VERSION
history.listen(onParentNavigate);
}, []);
return (
<div ref={ref} />
)
}