From 4fd3f03fd3f2dbc9bd06878b0940c2b63ac0757b Mon Sep 17 00:00:00 2001 From: jahooma Date: Wed, 15 Dec 2021 23:56:03 -0600 Subject: [PATCH] Prevent flash of 404 on user profile page. --- web/pages/[username]/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/pages/[username]/index.tsx b/web/pages/[username]/index.tsx index 921abd10..0ff086ac 100644 --- a/web/pages/[username]/index.tsx +++ b/web/pages/[username]/index.tsx @@ -6,7 +6,7 @@ import Error from 'next/error' export default function UserProfile() { const router = useRouter() - const [user, setUser] = useState(null) + const [user, setUser] = useState('loading') const atUsername = router.query.username as string | undefined const username = atUsername?.substring(1) || '' // Remove the initial @ useEffect(() => { @@ -16,6 +16,9 @@ export default function UserProfile() { }, [username]) const errorMessage = `Who is this "${username}" you speak of..` + + if (user === 'loading') return <> + return user ? ( ) : (