From 5629a80c3623f9b6c5882348ca45b2167da12773 Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Tue, 3 Sep 2024 00:13:08 +0900 Subject: useEffectを使ってwatchHasGitHubRepoがfalseになったときにリセットする MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SignUpForm3.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/SignUpForm3.tsx') diff --git a/src/SignUpForm3.tsx b/src/SignUpForm3.tsx index bfd71d0..e3b347d 100644 --- a/src/SignUpForm3.tsx +++ b/src/SignUpForm3.tsx @@ -1,4 +1,5 @@ import './SignUp.css' +import { useEffect } from 'react'; import { useForm } from 'react-hook-form' import { zodResolver } from "@hookform/resolvers/zod" import { useLocation, Navigate, useNavigate } from 'react-router-dom'; @@ -47,7 +48,10 @@ export const SignUpForm3Main = () => { (reposData.map((json: any) => (json['name']))) : [] - // TODO: watchHasGitHubRepo が false の場合は gitHubUsername と repoName が '' になって欲しい + useEffect(() => { + setValue('gitHubUsername', '') + setValue('repoName', '') + }, [watchHasGitHubRepo]) // form1, form2 のデータがない場合は form1 にリダイレクトする if (formData === null) { -- cgit v1.2.3