This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use next/router instead of react-router-dom
- Loading branch information
1 parent
4bccf79
commit d846fdd
Showing
3 changed files
with
11 additions
and
26 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import { useEffect } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import Router from 'next/router'; | ||
import { trackPage } from '../services/pirschClient'; | ||
|
||
const useTrackPage = () => { | ||
const location = useLocation(); | ||
|
||
useEffect(() => { | ||
trackPage().catch(console.error); | ||
}, [location.pathname]); | ||
const handleRouteChange = () => { | ||
trackPage().catch(console.error); | ||
}; | ||
|
||
Router.events.on('routeChangeComplete', handleRouteChange); | ||
|
||
return () => { | ||
Router.events.off('routeChangeComplete', handleRouteChange); | ||
}; | ||
}, []); | ||
}; | ||
|
||
export default useTrackPage; |
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