Skip to content

Commit

Permalink
Merge pull request #496 from nerdalert/bug-fix-hydration-error
Browse files Browse the repository at this point in the history
Fix the hydration error on the login page
  • Loading branch information
vishnoianil authored Jan 26, 2025
2 parents fa2c1ed + 61336d0 commit 7723df3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/app/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import DevModeLogin from './devmodelogin';
const Login: React.FunctionComponent = () => {
const [deploymentType, setDeploymentType] = useState<string | 'github'>();
const [isDevModeEnabled, setIsDevModeEnabled] = useState<boolean>(false);
const [isLoading, setIsLoading] = useState<boolean>(true);

useEffect(() => {
const chooseLoginPage = async () => {
Expand All @@ -21,16 +22,22 @@ const Login: React.FunctionComponent = () => {
} catch (error) {
console.error('Error fetching environment config:', error);
setDeploymentType('github');
} finally {
setIsLoading(false);
}
};
chooseLoginPage();
}, []);

// Don't render the page until the useEffect finishes fetching environment data
if (isLoading || deploymentType === null) {
return <div style={{ color: 'white', padding: '1rem' }}>Loading...</div>;
}

if (isDevModeEnabled) {
return <DevModeLogin />;
}
if (deploymentType === 'native') {
// Render a loading indicator or null while determining the environment
return <NativeLogin />;
}
return (
Expand Down

0 comments on commit 7723df3

Please sign in to comment.