• This repository has been archived on 28/Jul/2022
  • Stars
    star
    248
  • Rank 158,525 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

😎 πŸ“‹ React hooks for forms state and validation, less code more performant.

⚠️ Thank you for supporting me, this library isn't maintained anymore. Please consider other libraries.



React Cool Form

React hooks for forms state and validation, less code more performant.

npm version npm downloads coverage status All Contributors netlify deploy

Features

Docs

See the documentation at react-cool-form.netlify.app for more information about using React Cool Form!

Frequently viewed docs:

Quick Start

To use React Cool Form, you must use [email protected] or greater which includes hooks. This package is distributed via npm.

$ yarn add react-cool-form
# or
$ npm install --save react-cool-form

Here's the basic concept of how it rocks:

Edit RCF - Quick start

import { useForm } from "react-cool-form";

const Field = ({ label, id, error, ...rest }) => (
  <div>
    <label htmlFor={id}>{label}</label>
    <input id={id} {...rest} />
    {error && <p>{error}</p>}
  </div>
);

const App = () => {
  const { form, use } = useForm({
    // (Strongly advise) Provide the default values
    defaultValues: { username: "", email: "", password: "" },
    // The event only triggered when the form is valid
    onSubmit: (values) => console.log("onSubmit: ", values),
  });
  // We can enable the "errorWithTouched" option to filter the error of an un-blurred field
  // Which helps the user focus on typing without being annoyed by the error message
  const errors = use("errors", { errorWithTouched: true }); // Default is "false"

  return (
    <form ref={form} noValidate>
      <Field
        label="Username"
        id="username"
        name="username"
        // Support built-in validation
        required
        error={errors.username}
      />
      <Field
        label="Email"
        id="email"
        name="email"
        type="email"
        required
        error={errors.email}
      />
      <Field
        label="Password"
        id="password"
        name="password"
        type="password"
        required
        minLength={8}
        error={errors.password}
      />
      <input type="submit" />
    </form>
  );
};

✨ Pretty easy right? React Cool Form is more powerful than you think. Let's explore it now!

Articles / Blog Posts

πŸ’‘ If you have written any blog post or article about React Cool Form, please open a PR to add it here.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Welly

πŸ€” πŸ’» πŸ“– πŸš‡ 🚧

Chris

πŸ›

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

More Repositories

1

react-cool-inview

😎 πŸ–₯️ React hook to monitor an element enters or leaves the viewport (or another element).
TypeScript
1,462
star
2

react-cool-starter

😎 🐣 A starter boilerplate for a universal web app with the best development experience and a focus on performance and best practices.
TypeScript
1,306
star
3

use-web-animations

😎 🍿 React hook for highly-performant and manipulable animations using Web Animations API.
TypeScript
1,255
star
4

use-places-autocomplete

😎 πŸ“ React hook for Google Maps Places Autocomplete.
TypeScript
1,206
star
5

react-cool-virtual

😎 ♻️ A tiny React hook for rendering large datasets like a breeze.
TypeScript
1,195
star
6

react-cool-dimensions

😎 πŸ“ React hook to measure an element's size and handle responsive components.
TypeScript
941
star
7

react-cool-img

😎 🏞 A React <Img /> component let you handle image UX and performance as a Pro!
TypeScript
779
star
8

react-cool-portal

😎 πŸ’ React hook for Portals, which renders modals, dropdowns, tooltips etc. to <body> or else.
TypeScript
747
star
9

react-cool-onclickoutside

😎 πŸ–± React hook to listen for clicks outside of the component(s).
TypeScript
546
star
10

eslint-config-welly

😎 βš™οΈ ESLint configuration for React projects that I do. Feel free to use this!
JavaScript
21
star
11

use-transition-state

😎 πŸ‘Ÿ useTransition + useState = useTransitionState
JavaScript
12
star
12

wellyshen

πŸ€“ Hello I'm Welly.
3
star
13

welly-exchange

πŸ’° A currency exchange app made by React.
TypeScript
2
star
14

about-me

πŸ€“ About me.
HTML
2
star
15

wellyshen.github.io

LeadFit Privacy Policy
HTML
1
star