Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    react-form-hocpublic

    React-Form-HOC

    Travis David npm codecov.io

    Higher order component for react forms (inspired by redux-form)

    Installation

    $ npm install --save react-form-hoc
    

    Usage

    import formHOC from 'react-form-hoc'
     
    const MyForm = ({ fields }) => (
      <form>
        <input {...fields.firstName} />
        <input {...fields.lastName} />
      </form>
    )
     
    const Formed = formHOC({
      fiels: ['firstName', 'lastName'],
      validate: (key, value) => {
        switch (key) {
          case 'firstName':
            return value.length ? null : 'required'
          default:
            return null
        }
      }
    })(MyForm)
     
     
    <Formed onChange={(values, isValid) => {}} />

    Each field in the fields prop contains the value a onBlur, onChange, error (if preset) and the initalValue.

    License

    MIT © Christoph Hermann

    Keywords

    install

    npm i react-form-hoc

    Downloadsweekly downloads

    15

    version

    0.0.8

    license

    MIT

    repository

    githubgithub

    last publish

    collaborators

    • avatar