小编sak*_*ang的帖子

如何使用 useEffect() 进行验证

我正在尝试使用 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)

javascript validation reactjs

1
推荐指数
1
解决办法
5046
查看次数

标签 统计

javascript ×1

reactjs ×1

validation ×1