hooks-form
v1.0.0-alpha.1
Published
This is a simple react form management package based on the new famous Hooks API.
Downloads
9
Maintainers
Readme
Hooks Form
This is a simple react form management package based on the new famous Hooks API.
Usage
Install it:
yarn add hooks-form
Then use it!
import React from 'react';
import { Field, Form } from 'hooks-form';
...
// Submit handler
function handleSubmit(data) {
...
}
// TextInput component
function TextInput({ label, onChange, value }) {
return (
<div className="form-row">
<label>{label}</label>
<input type="text" onChange={onChange} value={value || ''} />
</div>
);
}
// Render your form
function App() {
return (
<Form name="createArticle" onSubmit={handleSubmit}>
<Field component={TextInput} name="title" label="Title" />
<Field component={TextInput} name="content" label="Content" />
<Field component={TextInput} name="author" label="Author" />
<Field component={TextInput} name="tags" label="Tags" />
<button type="submit">Publish</button>
</Form>
);
}
Documentation
Coming soon...