diff --git a/.changeset/perfect-baboons-relate.md b/.changeset/perfect-baboons-relate.md new file mode 100644 index 0000000000..d31fc9746c --- /dev/null +++ b/.changeset/perfect-baboons-relate.md @@ -0,0 +1,5 @@ +--- +"@blitzjs/generator": patch +--- + +Remove useEffect from reset password templates. diff --git a/apps/toolkit-app/src/pages/auth/reset-password.tsx b/apps/toolkit-app/src/pages/auth/reset-password.tsx index 439d3922f6..0a8ac72cbf 100644 --- a/apps/toolkit-app/src/pages/auth/reset-password.tsx +++ b/apps/toolkit-app/src/pages/auth/reset-password.tsx @@ -10,14 +10,10 @@ import { useMutation } from "@blitzjs/rpc" import Link from "next/link" const ResetPasswordPage: BlitzPage = () => { - const [token, setToken] = useState("") const router = useRouter() + const token = router.query.token?.toString() const [resetPasswordMutation, { isSuccess }] = useMutation(resetPassword) - useEffect(() => { - setToken(router.query.token as string) - }, [router.isReady]) - return (

Set a New Password

diff --git a/packages/generator/templates/app/src/pages/auth/reset-password.tsx b/packages/generator/templates/app/src/pages/auth/reset-password.tsx index 11430411cc..0a8ac72cbf 100644 --- a/packages/generator/templates/app/src/pages/auth/reset-password.tsx +++ b/packages/generator/templates/app/src/pages/auth/reset-password.tsx @@ -10,14 +10,10 @@ import { useMutation } from "@blitzjs/rpc" import Link from "next/link" const ResetPasswordPage: BlitzPage = () => { - const [token, setToken] = useState("") const router = useRouter() + const token = router.query.token?.toString() const [resetPasswordMutation, { isSuccess }] = useMutation(resetPassword) - useEffect(() => { - setToken(router.query.token as string) - }, [router.isReady]) - return (

Set a New Password

@@ -40,7 +36,7 @@ const ResetPasswordPage: BlitzPage = () => { }} onSubmit={async (values) => { try { - await resetPasswordMutation({...values, token}) + await resetPasswordMutation({ ...values, token }) } catch (error: any) { if (error.name === "ResetPasswordError") { return {