Skip to content

Commit

Permalink
Remove useEffect from reset password templates (#4051)
Browse files Browse the repository at this point in the history
Co-authored-by: Siddharth Suresh <[email protected]>
Co-authored-by: Brandon Bayer <[email protected]>
  • Loading branch information
3 people authored Feb 9, 2023
1 parent a3d8b28 commit 6ec020c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-baboons-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@blitzjs/generator": patch
---

Remove useEffect from reset password templates.
6 changes: 1 addition & 5 deletions apps/toolkit-app/src/pages/auth/reset-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
<h1>Set a New Password</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
<h1>Set a New Password</h1>
Expand All @@ -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 {
Expand Down

0 comments on commit 6ec020c

Please sign in to comment.