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!

selfhosted to remix

Maksim Mrug3879e6dbc013
diff --git a/app/hoc/Selfhosted.tsx b/app/hoc/Selfhosted.tsx
index b444783a6..8faed016f 100644
--- a/app/hoc/Selfhosted.tsx
+++ b/app/hoc/Selfhosted.tsx
@@ -1,9 +1,9 @@
import React, { useEffect } from 'react'
-import { useHistory } from 'react-router-dom'
+import { useNavigate, useLocation } from '@remix-run/react'
import _includes from 'lodash/includes'
import { isSelfhosted } from 'redux/constants'
-import routes from 'routes'
+import routes from 'routesPath'
const selfHostedBlacklist = [
routes.signup, routes.reset_password, routes.new_password_form, routes.main,
@@ -17,23 +17,17 @@ interface ISelfhosted {
}
const Selfhosted: React.FC<ISelfhosted> = ({ children }): JSX.Element => {
- const history = useHistory()
+ const navigate = useNavigate()
+ const location = useLocation()
// eslint-disable-next-line consistent-return
useEffect(() => {
if (isSelfhosted) {
- if (_includes(selfHostedBlacklist, window.location.pathname)) {
- history.push(DEFAULT_PAGE)
+ if (_includes(selfHostedBlacklist, location.pathname)) {
+ navigate(DEFAULT_PAGE)
}
-
- const unlisten = history.listen(({ pathname }: any) => {
- if (_includes(selfHostedBlacklist, pathname)) {
- history.push(DEFAULT_PAGE)
- }
- })
- return unlisten
}
- }, [history])
+ }, [location])
return children
}