📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
fix an App.tsx issue & typescriptify ScrollToTop
Blue Mousedf47e9649d79
diff --git a/src/hoc/ScrollToTop.jsx b/src/hoc/ScrollToTop.tsxsimilarity index 75%rename from src/hoc/ScrollToTop.jsxrename to src/hoc/ScrollToTop.tsxindex 5eedf7895..c0c220937 100644--- a/src/hoc/ScrollToTop.jsx+++ b/src/hoc/ScrollToTop.tsx@@ -1,7 +1,15 @@-import { useEffect } from 'react'+import React, { useEffect } from 'react'import { useHistory } from 'react-router-dom'import _isEmpty from 'lodash/isEmpty'+interface IScrollToTop {+ children: JSX.Element+}++interface StateType {+ scrollToTopDisable?: boolean+}+/*** A HOC which listens to history changes and scrolls to top of the page when triggered.*@@ -15,12 +23,12 @@ import _isEmpty from 'lodash/isEmpty'* @component* @param {HTMLElement} children The children covered by the listener.*/-const ScrollToTop = ({ children }) => {+const ScrollToTop: React.FC<IScrollToTop> = ({ children }) => {const history = useHistory()useEffect(() => {const unlisten = history.listen(({ hash, state }) => {- if (!_isEmpty(state) && state?.scrollToTopDisable) {+ if (!_isEmpty(state) && (state as StateType)?.scrollToTopDisable) {return}