-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Description
I have this component which is supposed to show a loader while it checks the auth state and then, if authenticated, show the child.
export function AuthGuard(child: HTMLElement) {
const authenticating = van.state(true);
const authenticated = van.state(false);
auth.onAuthStateChanged((user) => {
if (user) {
authenticated.val = true;
} else navigate(LOGIN_ROUTE);
authenticating.val = false;
});
if (authenticating.val || !authenticated.val) {
return div(
{ className: "w-full h-full grid place-items-center" },
Text({ align: "center" }, "Authenticating. Please wait...")
);
} else return child;
}The issue I run into is the tab freezes and from Chrome's tab manager, it just consumes memory at an exponential rate. I'm guessing using the authenticated.val in the function's body (and not in a derive or the content) causes an infinte binding.

How do I resolve this?
Metadata
Metadata
Assignees
Labels
No labels