1.0.0-beta.1 • Published 4 years ago

@uncontrolled/react v1.0.0-beta.1

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

@uncontrolled/react

Made with create-react-library

NPM JavaScript Style Guide

About Uncontrolled

Uncontrolled is a form component designed to complement use of HTML5 form fields and validation. There is no state management, no form field/control libraries to mess with, and no validation.

Why?

Because HTML has already done that for you and using the native HTML form fields (and validation) is incredibly simple. Check out the example below if you're skeptical. It's got state management and validaton baked in.

Validation

See the MDN docs on HTML Form validation: https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation

State Management

The DOM.

WARNING

This package is in alpha and there are no guarantees that version changes will retain backwards compatability. Use and update at your own risk.

That said, much of the API itself is likely settled.

Install

using yarn

yarn add @uncontrolled/react

using npm

npm i @uncontrolled/react

Usage

import React from 'react'
import useForm from '@uncontrolled/react'

function Example(props) {
  const {Form} = useForm()
  return React.useMemo(() => (
    <Form
      onSubmit={({ fieldData }) => {
        console.log({ fieldData });
      }}
    >
      <label>First Name</label>
      <input type="text" required min={2} name="firstName" />
      <button type="submit">Submit</button>
    </Form>
  ), []);
}

Working Example

Check out this fully working example on Codesandbox

License

MIT © brentmclark