Last active
December 30, 2022 21:13
-
-
Save drumnickydrum/2a7bfce0a0acd9f84f12f3e631d5b07c to your computer and use it in GitHub Desktop.
[React: Browser/Router Sync] Sync the browser's back button with react-router history.goBack #react #browser #router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useGoBackBrowserSync() { | |
useEffect(() => { | |
return history.listen((newLocation, action) => { | |
if (action === 'POP') { | |
history.goBack(); | |
} | |
}); | |
}, [history]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment