# forms-binding-react

> ``` yarn add forms-binding-react

Latest version **1.0.9** (published 2018-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install forms-binding-react
pnpm add forms-binding-react
yarn add forms-binding-react
bun add forms-binding-react
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2018-10-25 |
| First published | 2018-10-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 157.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Théo Herveux |
| Maintainers | hurobaki |
| Keywords | react, forms, HOC, Function As a Children Component |

## Links

- npm: https://www.npmjs.com/package/forms-binding-react
- Repository: https://github.com/Hurobaki/forms-binding-react
- npm.io page: https://npm.io/package/forms-binding-react

## Dependencies (3)

- [prop-types](https://npm.io/package/prop-types.md) 15.6.2
- [react-scripts](https://npm.io/package/react-scripts.md) 1.1.4
- [@babel/polyfill](https://npm.io/package/@babel/polyfill.md) 7.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2018-10-25
- 1.0.8 — 2018-10-25
- 1.0.7 — 2018-10-25
- 1.0.6 — 2018-10-24
- 1.0.5 — 2018-10-23
- 1.0.4 — 2018-10-23
- 1.0.3 — 2018-10-23
- 1.0.2 — 2018-10-23
- 1.0.1 — 2018-10-23
- 1.0.0 — 2018-10-23

## README

# Usage

```
yarn add forms-binding-react

npm install forms-binding-react
```

```js
// For HOC usage
import { withForm } from 'forms-binding-react'

// For Function As a Children Component
import { FormFACC } from 'forms-binding-react'
```

**withForm** example :

```js
import React, { Component } from 'react'
import { withForm } from 'forms-binding-react'

const validators = {
    username: addNamePredicate = value => value && /(?:\w){6,}/.test(value);
}

class FormPageComponent extends Component {
    render () {
        const {
              handleChange,
              handleSubmit,
              addPredicate,
              fields: { username },
              errors,
              formValid
            } = this.props;

        return (
            <form onSubmit={handleSubmit}>
                <InputForm
                    type="text"
                    name="username"
                    value={username}
                    labelTitle="Username"
                    error={errors.username}
                    handleChange={handleChange}
                    setPredicate={addPredicate("username", validators.username)}
                />
                <button
                    type="submit"
                    disabled={!formValid}
                >
                    Submit
                </button>
            </form>
        )
    }
}

export const FormPage = withForm(FormPageComponent)
```

**formFACC** example :

```js
import React, { Component } from 'react'
import { FormFACC } from 'forms-binding-react'

const validators = {
    username: addNamePredicate = value => value && /(?:\w){6,}/.test(value);
}

class FormPageComponent extends Component {
    render () {
        return (
            <FormFACC>
            {({
                handleChange,
                handleSubmit,
                addPredicate,
                fields: { username },
                errors,
                formValid
            }) => (
                 <form onSubmit={handleSubmit}>
                    <InputForm
                        type="text"
                        name="username"
                        value={username}
                        labelTitle="Username"
                        error={errors.username}
                        handleChange={handleChange}
                        setPredicate={addPredicate("username", validators.username)}
                    />
                    <button
                        type="submit"
                        disabled={!formValid}
                    >
                        Submit
                    </button>
                 </form>
            )}
            </FormFACC>
        )
    }
}

export const FormPage = FormPageComponent
```

---
_Source: https://npm.io/package/forms-binding-react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
