I implement page navigations with react-router. When moving from B to A after moving from A to B, needs page back behavior. Therefore, I wrote bellow.
import { useHistory } from 'react-router';
const history = useHisotry()
history.goBack();
It works well. But I have my doubts about it.
I can use window.hisotry.back()
instead of useHisotry() back
.
Why use useHistory goBack function instead of window history back function?