# redux-mini-form

> A minimal redux form

Latest version **0.0.11** (published 2018-07-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-mini-form
pnpm add redux-mini-form
yarn add redux-mini-form
bun add redux-mini-form
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.11 |
| Published | 2018-07-11 |
| First published | 2018-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 441.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yu Li |
| Maintainers | lijingyu68 |
| Keywords | react, reactjs, flux, redux, react-redux, redux-mini-form, form, hoc |

## Links

- npm: https://www.npmjs.com/package/redux-mini-form
- Repository: https://github.com/eavesal/redux-mini-form
- Homepage: https://github.com/eavesal/redux-mini-form#readme
- Issues: https://github.com/eavesal/redux-mini-form/issues
- npm.io page: https://npm.io/package/redux-mini-form

## Dependencies (7)

- [ramda](https://npm.io/package/ramda.md) ^0.25.0
- [react](https://npm.io/package/react.md) ^16.3.2
- [redux](https://npm.io/package/redux.md) ^4.0.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.3.2
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.1
- [react-redux](https://npm.io/package/react-redux.md) ^5.0.7
- [lodash.debounce](https://npm.io/package/lodash.debounce.md) ^4.0.8

## 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

- 0.0.11 (latest) — 2018-07-11
- 0.0.10 — 2018-06-01
- 0.0.8 — 2018-05-28
- 0.0.7 — 2018-05-27
- 0.0.6 — 2018-05-24
- 0.0.5 — 2018-05-24
- 0.0.4 — 2018-05-21
- 0.0.3 — 2018-05-11
- 0.0.2 — 2018-05-10
- 0.0.1 — 2018-05-10

## README

# redux-mini-form

[![Build Status](https://travis-ci.org/eavesal/redux-mini-form.svg?branch=master)](https://travis-ci.org/eavesal/redux-mini-form)

`redux-mini-form` is a minimal form solution that supply basic form operations and works with `React` and `Redux`.

## Examples

* [Simple Form](https://github.com/eavesal/redux-mini-form/tree/master/examples/simple)
* [Submit Validation Form](https://github.com/eavesal/redux-mini-form/tree/master/examples/submit-validation)
* [Sync Validation Form](https://github.com/eavesal/redux-mini-form/tree/master/examples/sync-validation)
* [Wizard Form](https://github.com/eavesal/redux-mini-form/tree/master/examples/wizard-form)

## Overview

The basic concept for `redux-mini-form` is simple. We use a HOC `withForm` to do CURD operations to redux store and supply some CURD method in React context. And also we use `withField` to consume the context and supply necessary method to field component.

## Quick Start

### Installation

```bash
$ npm install --save redux-mini-form
```

or

```bash
$ yarn add redux-mini-form
```

### Usage Example

Suppose we want to build a simple form with a field named username. And we want use `redux-mini-form` to track the changes in redux store and log the value when user submited this form.

First, we bring the form reducer to our global store.

```jsx
import {Provider, connect} from 'react-redux'
import {formReducer} from 'redux-mini-form'

const reducer = combineReducers({
  form: formReducer, // Currently, we only support the `formReducer` to be a child of root reducer and named `form`.
})
const store = createStore(reducer)
```

Second, we can create our own field component or use the build-in field.

```jsx
import {InputField} from 'redux-mini-form'

// Use the build-in InputField
const UsernameInputField = (...props) =>
	<InputField name='username' {...props} />

// Build your own InputField
const CustomizedInputField = ({onChange, value}) =>
	<input onChange={onChange} name='username' value={value} />
const UsernameInputField = withField({
  parse: (e) => e.target.value,
})(CustomizedInputField)
```

Third, we can create our own `UsernameInputField` in a form.

```jsx
import {
  withForm,
  Form
} from 'redux-mini-form'

const SimpleForm = ({onSubmit, formId, onReset}) => (
  <Form onSubmit={onSubmit} formId={formId}> // The `Form` component comes from redux-mini-form is not necessary, you can build your own Form component.
    <UsernameInputField/>
  </Form>
)

export default withForm()(SimpleForm)
```

Now, we can use our `SimpleForm` in our app like this.

```jsx
// onSubmit have all field values as a parameter.
<SimpleForm formId='SIMPLE_FORM' onSubmit={() => null} />
```

## Documentation

In progress.

## Building examples from sources

```bash
$ git clone git@github.com:eavesal/redux-mini-form.git
$ cd redux-mini-form/examples/simple-form # or other exaples from examples folder
$ npm install
$ npm run ci
```

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