formite-components
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

formite-components

Easy forms with React hooks and class components.

Use formite with HTML class components.

Installation

npm install formite-core formite-components

or

yarn add formite-core formite-components

Usage

import { InputField, Form } from "formite-components"

const logSubmitted = action("submitted");

const handleSubmit = async (values: unknown) => {
    console.log(values);
};

class SimpleForm extends React.Component {
    public render() {
        return (
            <Form initialValues={{ firstName: "", lastName: "" }} onSubmitForm={handleSubmit}>
                {(form, fields) => (
                    <fieldset>
                        <InputField field={fields.firstName}>
                            {field => <input type="text" placeholder="First name" {...field} />}
                        </InputField>
                        <InputField field={fields.lastName}>
                            {field => <input type="text" placeholder="Last name" {...field} />}
                        </InputField>
                        <button type="submit" disabled={!(form.canSubmit && form.isDirty)}>Save</button>
                    </fieldset>
                )}
            </Form>
        );
    }
}

See Storybook for more examples.

Readme

Keywords

Package Sidebar

Install

npm i formite-components

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

45.6 kB

Total Files

32

Last publish

Collaborators

  • joerneu