• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Performant 2KB React library to manage your forms

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):


Laurens Lavaert

💻

Jovi De Croock

🚇 ⚠️ 👀 📖 💻

Jonathan Callewaert

🐛

Andrew Rempe

💻

Corentin Leruth

💻

Pavel Ravits

🐛

Tegan Churchill

🐛

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

More Repositories

1

webpack-module-nomodule-plugin

Easily implement a module nomodule index.html
JavaScript
84
star
2

use-web-animation

Hooks to leverage the web-animations API in under a kb
TypeScript
52
star
3

POC-ModularLegacyBuild

Module-nomodule implementation that has grown to more than just a POC
JavaScript
33
star
4

preact-urql

Preact bindings for urql
27
star
5

pranimate

Hooks-based animations for Preact
TypeScript
25
star
6

product-boilerplate

JavaScript
20
star
7

Vanilla-Preact-Application

JavaScript
20
star
8

realworld

CSS
8
star
9

React-angler

POC to make functional components have a similar API to class components. This by using Hooks to our best use.
TypeScript
8
star
10

MobX-Form

Store 4 Free MobX Form Library
TypeScript
8
star
11

urql-svelte-kit

Svelte
7
star
12

blog-portfolio

TypeScript
6
star
13

threed-web

JavaScript
5
star
14

webpack-syntax-resolver-plugin

A resolver that respects the syntax field proposal
JavaScript
4
star
15

carlo-server-react-template

JavaScript
4
star
16

sanity-migrate

JavaScript
3
star
17

gatsby-template-preact

JavaScript
3
star
18

groq-types

JavaScript
3
star
19

E57-visualizer

JavaScript
3
star
20

trade-rs

Rust
2
star
21

bachelorproef

HTML
2
star
22

Advent-of-code

Reason
2
star
23

react-a11y-hooks

TypeScript
2
star
24

sanity-translation-examples

Studio with Localization
JavaScript
1
star
25

babel-plugin-preact-hooks

JavaScript
1
star
26

gql-server-poc

Nothing to see here!
TypeScript
1
star
27

wmr-cloudflare-pages

JavaScript
1
star
28

JoviDeCroock

1
star
29

inline-func-poc

JavaScript
1
star
30

preact-worker

JavaScript
1
star
31

serverless-graphql

TypeScript
1
star
32

gatsby-starter-netlify-cms

JavaScript
1
star
33

POC-network-aware-bundle

JavaScript
1
star