📈 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: check for isLoading for auth before redirecting
Blue Mousea83a05ba8f5c
diff --git a/web/app/hoc/protected.tsx b/web/app/hoc/protected.tsxindex a101b6638..3049ec00c 100644--- a/web/app/hoc/protected.tsx+++ b/web/app/hoc/protected.tsx@@ -26,7 +26,7 @@ export const withAuthentication = <P extends PropsType>(WrappedComponent: any, aconst WithAuthentication = (props: P) => {const { shouldBeAuthenticated, redirectPath } = authParamconst navigate = useNavigate()- const { isAuthenticated } = useAuth()+ const { isAuthenticated, isLoading } = useAuth()// We need to use ref to avoid 404 errors - https://github.com/remix-run/react-router/pull/12853const navigating = useRef(false)@@ -36,13 +36,17 @@ export const withAuthentication = <P extends PropsType>(WrappedComponent: any, areturn}+ if (isLoading) {+ return+ }+if (shouldBeAuthenticated !== isAuthenticated) {navigate(redirectPath)navigating.current = true}// TODO: Investigate this later. https://github.com/remix-run/react-router/discussions/8465// eslint-disable-next-line react-hooks/exhaustive-deps- }, [isAuthenticated, shouldBeAuthenticated])+ }, [isAuthenticated, shouldBeAuthenticated, isLoading])// if (!selector) {// return null