5.0.1 โ€ข Published 4 years ago

hooked-form v5.0.1

Weekly downloads
119
License
MIT
Repository
github
Last release
4 years ago

Hooked-Form

npm version All Contributors Build Status Bundle size codecov

Documentation

Example

๐ŸŒ Installation

yarn

  yarn add hooked-form

npm

  npm i --save hooked-form

UMD

dev:

<script src="https://unpkg.com/hooked-form@latest/dist/hooked-form.umd.js"></script>

๐ŸŽจ Example

import React from 'react';
import { HookedForm, useField } from 'hooked-form';

const StringField = ({ fieldId, label }) => {
  const [{ onChange }, { touched, error, value }] = useField(fieldId);
  const onInput = React.useCallback(e => onChange(e.currentTarget.value), [
    onChange,
  ]);
  return (
    <label>
      {label + ' '}
      <input value={value} onChange={onInput} />
      {touched && error && <div>{error}</div>}
    </label>
  );
};

const App = () => {
  return (
    <HookedForm
      onSubmit={console.log}
      validateOnBlur
      initialValues={React.useMemo(() => ({ name: '' }), [])}
      validate={values => (values.name ? {} : { name: 'Required' })}
    >
      <h3>Hooked Form</h3>
      <StringField label="Name:" fieldId="name" />
      <input type="submit" value="Submit" />
    </HookedForm>
  );
};

render(<App />, document.body);

๐Ÿ’ฟ Modern build

This library offers a modern build (ES2015 output), this is smaller and parses faster in the browser. So if you don't plan to target older browsers feel free to use this.

Webpack

  "resolve": {
    "alias": {
      "hooked-form": "hooked-form/dist/hooked-form.modern.js"
    }
  }

Parcel

  "alias": {
    "hooked-form": "hooked-form/dist/hooked-form.modern.js"
  }

๐Ÿ“ข Credits

๐Ÿ˜Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

5.0.1

4 years ago

5.0.0

4 years ago

4.3.3

4 years ago

4.3.2

4 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.3.0-beta.0

4 years ago

4.2.3

4 years ago

4.2.2

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.0

4 years ago

4.0.0-beta.0

4 years ago

4.0.0-alpha.2

4 years ago

3.2.0

5 years ago

3.1.1

5 years ago

4.0.0-alpha.1

5 years ago

4.0.0-alpha.0

5 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.3.0

5 years ago

2.3.0-alpha.0

5 years ago

2.3.0-alpha

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

2.0.0-beta.0

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.2.0-alpha.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago