https://codesandbox.io/s/react-router-689yc
Instead of BrowserRouter, use Router with customized history
then use the hook _useHistory()_ and see the different object return by history
to return history object with properties
return properties from history object
TLDR:
_goBack_ and _goForward_ methods are undefined
for history object when using custom history with Router component
Remove 'history' dependency from package.json file and that will do the trick (at least on your test case). @pankaj-ch
Only history 4.x works with Router 5.x.
Most helpful comment
Only history 4.x works with Router 5.x.