Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/trs/use-form

Manage form state with React hooks automagically.
https://github.com/trs/use-form

Last synced: 23 days ago
JSON representation

Manage form state with React hooks automagically.

Awesome Lists containing this project

README

        

# `use-form`

Manage form state with React hooks automagically.

## Install

`npm install @trs/use-form`

_or_

`yarn add @trs/use-form`

## Usage

```tsx
import React from 'react';
import ReactDOM from 'react-dom';

import {useForm, useSubmit, useChange} from '@trs/use-form`;

const App = () => {
const {control, Form} = useForm({username: '', password: ''});

useChange(control, 'username', (value) => {
console.log(`Username changed to: ${username}`);
});

useSubmit(control, (state) => {
loginToAPI(state.username, state.password);
});

return (




);
};

ReactDOM.render(, document.getElementById('app'));

```

## API

### `useForm`

### `useChange`

### `useSubmit`