react-formit
Super simple and super flexible React form.
$ yarn add react-formit
Usage
Bare minimum
; const App = <Formit action="/"> <form onSubmit=onSubmit> <label htmlFor="username">Username:</label> <input type="text" id="username" onChange= value= required /> <label htmlFor="password">Password:</label> <input type="password" id="password" onChange= value= required /> <button type="submit">Submit</button> </form> </Formit>; ;
Full package
; const App = <Formit action="/" method="POST" // default defaultFields= name: 'username' value: 'Stian' name: 'password' value: 'mightyPassword' credentials="same-origin" headers= Authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ' onValueSet= console beforeSubmit= window onSuccessfulSubmit= console onFailedSubmit= console responseAsJSON dontFlushFieldsOnSubmit > onSubmit setFields setValue getValue clearValues isPosting postingError response responseData <form onSubmit=onSubmit> <label htmlFor="username">Username:</label> <input type="text" id="username" onChange= value= required /> <label htmlFor="password">Password:</label> <input type="password" id="password" onChange= value= required /> <label htmlFor="both">Set both:</label> <input type="text" id="both" onChange= value= required /> <button type="submit" disabled=isPosting> isPosting ? 'Submitting...' : 'Submit' </button> <a onClick=clearValues>Cancel</a> responseData !== null && <p>responseDatamySuccessMessage</p> </form> </Formit>; ;