rc-use-form
manage form state use React Hooks. https://ariesjia.github.io/react-use-form/
Install
// use yarnyarn add rc-use-form// use npmnpm install rc-use-form
Demo
simple
; const Demo = { const form field = const handleSubmit = { event console } return <div> <form onSubmit=handleSubmit> <div> <label>username</label> <input type="text" .../> </div> <div> <label>password</label> <input type="password" ... /> </div> <button type='submit'>submit</button> </form> </div> }
validate
; const Demo = { const form field = const handleSubmit = { event form } return <div> <form onSubmit=handleSubmit> <div> <label>username</label> <input type="text" ... /> formerrorsname && <div> formerrorsname0message </div> </div> <div> <label>password</label> <input type="password" ... /> formerrorspassword && <div> formerrorspassword0message </div> </div> <button type='submit'>submit</button> </form> </div> }
form
value
: The form datatouched
: The field had been changed by usererrors
: The form validate errorsvalidate
: The form validate functiongetValue
: The form getValue function, always return current value
field
name
: The field field (required).
Options
rules
: validate rules use async-validate