@dock365/react-form
v0.4.4
Published
React components for form and input field management
Downloads
14
Readme
React Form
Install
1 Install react form as dependency
# Using yarn package manager
$ yarn add @dock365/react-form
# Using npm package manager
$ npm install --save @dock365/react-form
2 Import React form module
// ES6
import { Form } from "@dock365/react-form"
// ES5
var Form = require("@dock365/react-form").Form;
Example
import React from "react";
import { Form, Field } from "@dock365/react-form";
export default (props) => {
return (
<Form onSubmit={(e, values) => console.log(values)} validateOn={1}>
<Field name="test1" render={(props) => (
<div>
<input {...props.input} />
<ul>
{props.errors.map((error, i) => <li key={i}>{error}</li>)}
</ul>
</div>
)}
validationRules={{
required: true,
maxLength: 10,
}} />
<Field name="test2" render={(props) => <input {...props.input} />} />
<Field name="test3" render={(props) => <input {...props.input} />} />
<button>Submit</button>
</Form>
);
};
Contributing!
All contributions are super welcome!
License
React Form is MIT licensed.