Skip to content

Commit 6ec020c

Browse files
tordanssiddhsureshflybayer
authored
Remove useEffect from reset password templates (#4051)
Co-authored-by: Siddharth Suresh <[email protected]> Co-authored-by: Brandon Bayer <[email protected]>
1 parent a3d8b28 commit 6ec020c

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

.changeset/perfect-baboons-relate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@blitzjs/generator": patch
3+
---
4+
5+
Remove useEffect from reset password templates.

apps/toolkit-app/src/pages/auth/reset-password.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ import { useMutation } from "@blitzjs/rpc"
1010
import Link from "next/link"
1111

1212
const ResetPasswordPage: BlitzPage = () => {
13-
const [token, setToken] = useState("")
1413
const router = useRouter()
14+
const token = router.query.token?.toString()
1515
const [resetPasswordMutation, { isSuccess }] = useMutation(resetPassword)
1616

17-
useEffect(() => {
18-
setToken(router.query.token as string)
19-
}, [router.isReady])
20-
2117
return (
2218
<div>
2319
<h1>Set a New Password</h1>

packages/generator/templates/app/src/pages/auth/reset-password.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ import { useMutation } from "@blitzjs/rpc"
1010
import Link from "next/link"
1111

1212
const ResetPasswordPage: BlitzPage = () => {
13-
const [token, setToken] = useState("")
1413
const router = useRouter()
14+
const token = router.query.token?.toString()
1515
const [resetPasswordMutation, { isSuccess }] = useMutation(resetPassword)
1616

17-
useEffect(() => {
18-
setToken(router.query.token as string)
19-
}, [router.isReady])
20-
2117
return (
2218
<div>
2319
<h1>Set a New Password</h1>
@@ -40,7 +36,7 @@ const ResetPasswordPage: BlitzPage = () => {
4036
}}
4137
onSubmit={async (values) => {
4238
try {
43-
await resetPasswordMutation({...values, token})
39+
await resetPasswordMutation({ ...values, token })
4440
} catch (error: any) {
4541
if (error.name === "ResetPasswordError") {
4642
return {

0 commit comments

Comments
 (0)