我正在尝试使用 useState() 和 useEffect() 验证表单
这是我的 useEffect() 方法:
/ for every change in our state this will be fired
// we add validation here and disable the save button if required
useEffect(() => {
// we want to skip validation on first render
if (firstRender.current) {
firstRender.current = false
return
}
// here we can disable/enable the save button by wrapping the setState function
// in a call to the validation function which returns true/false
//setDisabled(formValidation())
formValidation();
}, [fullName,email,password]) …
Run Code Online (Sandbox Code Playgroud)