From dd993e091e3982c18390d39f98a3843cecd6986e Mon Sep 17 00:00:00 2001 From: Nicco Date: Thu, 26 Sep 2019 21:30:28 +0200 Subject: [PATCH] Update README.md --- README.md | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 071bb4a..9f75b33 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,82 @@ # formhero -Fully customisable React form utility + +Fully customisable react form utility. + +## ✓ Features + +- Typescript compatible +- Customizable extractor, validator, getter and setters. (More in the docs) +- No Deps +- Miniscule () + +## 🚀 Quickstart + +```tyimport React from 'react' +import ReactDOM from 'react-dom' +import { useForm } from 'formhero' + +const Form = () => { + + const { auto, form, errors } = useForm({ + username: '', + password: '', + type: 'formhero', + awesome: true, + }, { + username: /^test/, + password: { + validator: /^.{3,}$/, + message: 'To short', + }, + awesome: (value) => !!value + }) + + const _submit = (e: React.FormEvent) => { + e.preventDefault() + console.log(form, errors) + } + + return ( +
+
+ +
Username
+ + {errors.username && 'Something went wrong'} +
+ +
Password
+ +
+ +
Which one to choose?
+ +
+ +
Is it awesome?
+ e.target.checked + })} /> +
+ + +
+
+ ) +} +``` + +## 📖 Docs + +### `useForm` + +```typescript +const {auto, errors, update, form} = useForm(initial, validators, options) +```