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 protected HOC

Blue Mouse9c74a3d467e2
diff --git a/app/hoc/protected.tsx b/app/hoc/protected.tsx
index 85b25ed7c..f0de91f32 100644
--- a/app/hoc/protected.tsx
+++ b/app/hoc/protected.tsx
@@ -1,4 +1,4 @@
-import React from 'react'
+import React, { useEffect } from 'react'
import { useSelector } from 'react-redux'
import { useNavigate } from '@remix-run/react'
@@ -30,8 +30,13 @@ export const withAuthentication = <P extends PropsType>(WrappedComponent: any, a
const selector = useSelector(authParam.selector)
const navigate = useNavigate()
+ useEffect(() => {
+ if (!selector) {
+ navigate(authParam.redirectPath)
+ }
+ }, [selector])
+
if (!selector) {
- navigate(authParam.redirectPath)
return null
}