Skip to content

Commit

Permalink
hotfix(dashboard): infinite user reload on set-up pages (#1191)
Browse files Browse the repository at this point in the history
  • Loading branch information
IGassmann committed Feb 27, 2024
1 parent d775e23 commit 2e5fe2a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ui/apps/dashboard/src/app/(auth)/ReloadClerkAndRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ type ReloadClerkAndRedirectProps = {
* @param {string} redirectURL - The URL to redirect to after reloading Clerk
*/
export default function ReloadClerkAndRedirect({ redirectURL }: ReloadClerkAndRedirectProps) {
const { user } = useUser();
const { isLoaded, user } = useUser();

useEffect(() => {
if (!isLoaded) return;

user?.reload().then(() => {
window.location.href = redirectURL;
window.location.replace(redirectURL);
});
}, [user, redirectURL]);
// eslint-disable-next-line react-hooks/exhaustive-deps -- We don't want to run this effect when the user changes as this would cause an infinite loop
}, [isLoaded, redirectURL]);

return (
<div className="flex h-full w-full items-center justify-center">
Expand Down

0 comments on commit 2e5fe2a

Please sign in to comment.