@braces/reform
v0.4.1
Published
React components for form and input field management
Downloads
9
Readme
React Form
Requirement
React version 16.4.0 is required. To work on older version of react use @braces/reform version 4.0.0 or older.
Install
1 Install react form as dependency
# Using yarn package manager
$ yarn add @braces/reform
# Using npm package manager
$ npm install --save @braces/reform
2 Import React form module
// ES6
import { Form } from "@braces/reform"
// ES5
var Form = require("@braces/reform").Form;
Example
import React from "react";
import { Form, Field } from "@braces/reform";
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.