Created
September 27, 2019 02:07
-
-
Save pwener/9dc22d5361153f22a409eefe2752b801 to your computer and use it in GitHub Desktop.
Get changes of pathname using history in React functional
This file contains hidden or 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
| const [pathname, setPathname] = useState(history.location.pathname); | |
| useEffect(() => { | |
| history.listen((location) => { | |
| setPathname(location.pathname); | |
| }); | |
| }, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment