MCPcopy Create free account
hub / github.com/dailydotdev/apps / ProtectedPage

Function ProtectedPage

packages/webapp/components/ProtectedPage.tsx:19–36  ·  view source on GitHub ↗
({
  children,
  fallback,
  shouldFallback,
}: ProtectedPageProps)

Source from the content-addressed store, hash-verified

17 }).toString()}`;
18
19function ProtectedPage({
20 children,
21 fallback,
22 shouldFallback,
23}: ProtectedPageProps): ReactElement {
24 const router = useRouter();
25 const { tokenRefreshed, user } = useContext(AuthContext);
26
27 useEffect(() => {
28 if (tokenRefreshed && !user) {
29 router.replace(getOnboardingRedirect(router.asPath || '/'));
30 }
31 // @NOTE see https://dailydotdev.atlassian.net/l/cp/dK9h1zoM
32 // eslint-disable-next-line react-hooks/exhaustive-deps
33 }, [router, tokenRefreshed, user]);
34
35 return <>{shouldFallback ? fallback : children}</>;
36}
37
38export default ProtectedPage;

Callers

nothing calls this directly

Calls 3

replaceMethod · 0.80
getOnboardingRedirectFunction · 0.70
useRouterFunction · 0.50

Tested by

no test coverage detected