From 0a5069ba7fc69fd90f7ffc5813763d8a0e182f79 Mon Sep 17 00:00:00 2001 From: Aswin V Date: Fri, 4 Mar 2022 17:21:24 +0530 Subject: [PATCH] Check if router is ready (#17) --- pages/saml/login.tsx | 73 +++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/pages/saml/login.tsx b/pages/saml/login.tsx index f30afae..ad48c6b 100644 --- a/pages/saml/login.tsx +++ b/pages/saml/login.tsx @@ -6,6 +6,7 @@ import { useEffect, useRef, useState } from 'react'; export default function Login() { const router = useRouter(); const { id, audience, acsUrl, providerName, relayState } = router.query; + const isRouteReady = router.isReady; const [state, setState] = useState({ username: 'jackson', @@ -25,7 +26,7 @@ export default function Login() { acsUrlInp.current.focus(); acsUrlInp.current.select(); } - }, []); + }, [acsUrl]); const handleChange = (e: FormEvent): void => { const { name, value } = e.currentTarget; @@ -75,41 +76,43 @@ export default function Login() {

Login

- {acsUrl ? null : ( -
-
- - + {isRouteReady ? ( + acsUrl ? null : ( +
+
+ + +
+
+ + +
-
- - -
-
- )} + ) + ) : null}