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!

project protected to remix

Maksim Mrugb86979aba12a
diff --git a/app/hoc/projectProtected.tsx b/app/hoc/projectProtected.tsx
index 3529d40d1..3dde70492 100644
--- a/app/hoc/projectProtected.tsx
+++ b/app/hoc/projectProtected.tsx
@@ -1,11 +1,11 @@
import React from 'react'
import { useSelector } from 'react-redux'
-import { Redirect, useParams } from 'react-router-dom'
+import { useNavigate, useParams } from '@remix-run/react'
import _find from 'lodash/find'
import _replace from 'lodash/replace'
import { StateType } from 'redux/store'
-import routes from 'routes'
+import routes from 'routesPath'
type PropsType = {
[key: string]: any
@@ -15,6 +15,7 @@ export const withProjectProtected = <P extends PropsType>(WrappedComponent: any)
const WithProjectProtected = (props: P) => {
const passwords = useSelector((state: StateType) => state.ui.projects.password)
const projects = useSelector((state: StateType) => state.ui.projects.projects)
+ const navigate = useNavigate()
const { id }: {
id: string
@@ -27,7 +28,8 @@ export const withProjectProtected = <P extends PropsType>(WrappedComponent: any)
}
if (project?.isPasswordProtected && !passwords[id]) {
- return <Redirect to={_replace(routes.project_protected_password, ':id', id)} />
+ navigate(_replace(routes.project_protected_password, ':id', id))
+ return null
}
return <WrappedComponent {...props} />