From 6ec020c6d67d18c074d4064c2a4d63bfa9c83d5c Mon Sep 17 00:00:00 2001 From: Tobias Date: Thu, 9 Feb 2023 06:49:10 +0100 Subject: [PATCH] Remove useEffect from reset password templates (#4051) Co-authored-by: Siddharth Suresh Co-authored-by: Brandon Bayer --- .changeset/perfect-baboons-relate.md | 5 +++++ apps/toolkit-app/src/pages/auth/reset-password.tsx | 6 +----- .../templates/app/src/pages/auth/reset-password.tsx | 8 ++------ 3 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 .changeset/perfect-baboons-relate.md 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 {