A simple form management for Mobx & React.
npm install mobx-formsA simple form manager for React and Mobx.
> Heavily inspired by and based on Redux Form! Be sure to check it out if you're a Redux fan.
- [ ] namespace types
- [ ] add docs
1. finish the api (mainly submitting/async validation)
4. better README :blush:
npm i --save mobx-forms
Use Provider from mobx-react and supply the form store to it as mobxForms.
``javascript
import { FormsStore } from 'mobx-forms';
import { Provider } from 'mobx-react';
import YourApp from './YourApp';
const Root = () =>
export default Root;
`
Initializing a form:
`javascript
import React from 'react';
import { observer } from 'mobx-react';
import { mobxForm, Field, FieldArray } from 'mobx-forms';
const Form = props => (
export default mobxForm({
form: 'myForm',
})(Form);
`FlatArray
Example of a and DeepArray:
`javascript
const FlatArray = observer(props =>
{props.fields.map((index) =>
key={index}
index={index}
component="input"
/>
)}
);
const DeepArray = observer(props =>
That's it! You will get the form's instance as a prop named
form.Field` accepts either a string or a component. It will receive the necessary properties. More detailed docs incoming.