Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fixed some TS warnings

Blue Mouse8d09868f22b6
diff --git a/src/hoc/ScrollToTop.tsx b/src/hoc/ScrollToTop.tsx
index c0c220937..66ac0a95b 100644
--- a/src/hoc/ScrollToTop.tsx
+++ b/src/hoc/ScrollToTop.tsx
@@ -10,6 +10,11 @@ interface StateType {
scrollToTopDisable?: boolean
}
+interface IHistoryListener {
+ hash: string
+ state?: StateType | null
+}
+
/**
* A HOC which listens to history changes and scrolls to top of the page when triggered.
*
@@ -27,8 +32,10 @@ const ScrollToTop: React.FC<IScrollToTop> = ({ children }) => {
const history = useHistory()
useEffect(() => {
- const unlisten = history.listen(({ hash, state }) => {
- if (!_isEmpty(state) && (state as StateType)?.scrollToTopDisable) {
+ const unlisten = history.listen((location) => {
+ const { hash, state } = location as IHistoryListener
+
+ if (!_isEmpty(state) && state?.scrollToTopDisable) {
return
}