@doguh/react-form

1.0.1 • Public • Published

react-form

NPM JavaScript Style Guide

Install

npm install --save @doguh/react-form

Usage

import React, { Component } from 'react';

import { Form, Field } from '@doguh/react-form';

class Example extends Component {
  state = {
    user: {
      name: 'Señor Chang',
    },
  };

  render() {
    return (
      <Form
        values={this.state.user}
        onSubmit={values => {
          console.log(values);
          this.setState({ user: values });
        }}
      >
        <label>
          Name <Field name="name" type="text" />
        </label>
        <label>
          Over 18 <Field name="accept" type="checkbox" />
        </label>
        <div>
          Gender
          <label>
            Male <Field name="gender" value="male" type="radio" />
          </label>
          <label>
            Female <Field name="gender" value="female" type="radio" />
          </label>
          <label>
            Other <Field name="gender" value="other" type="radio" />
          </label>
        </div>
        <button type="submit">Submit</button>
      </Form>
    );
  }
}

License

MIT © doguh

Dependencies (0)

    Dev Dependencies (27)

    Package Sidebar

    Install

    npm i @doguh/react-form

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    46.1 kB

    Total Files

    6

    Last publish

    Collaborators

    • doguh