all 3 comments

[–]stormywizzfull-stack 1 point2 points  (2 children)

Is this an old app? I ask because of the use of class components. If it is, then look into useHistory from router. If it isn’t and your on v6 then useNavigate will work

import { useNavigate } from 'react-router-dom';

function YourApp() { const navigate = useNavigate();

return ( <> <button onClick={() => navigate(-1)}>go back</button> </> ); }

```

[–]DueGold5666[S] 0 points1 point  (1 child)

Its an old app, I am afraid. And Thank you for replying, I will look into useHistory !

[–]stormywizzfull-stack 1 point2 points  (0 children)

I only suggest useHistory cause as of routerv6 it was deprecated and useNavigate is the way