0.1.1 • Published 8 years ago
mobx-react-form-hoc v0.1.1
mobx-react-form-hoc 
Simplify mobx-react-form by using a higher order component
Installation
mobx-react-form-hoc is available as an npm package.
npm install mobx-react-form-hocUsage
import React from "react";
import { observer } from "mobx-react";
import validatorjs from "validatorjs";
import withForm from "mobx-react-form-hoc";
const LoginForm = () => {
return (
<form>
<fieldset>
<label htmlFor={form.$("email").id}>
{form.$("email").label}
</label>
<input {...form.$("email").bind()} />
<p>{form.$("email").error}</p>
</fieldset>
</form>
);
};
const events = {
onSuccess(props, form) {
console.log(form.values());
}
};
const fields = {
email: {
label: "eMail",
placeholder: "Enter your eMail address",
rules: "required|email|string|between:5,25"
}
};
const plugins = {
dvr: validatorjs
};
export default withForm({ fields, plugins, events }, observer(LoginForm));Documentation
please have a look into the documentation of mobx-react-form
Related
Contributing
This project was bootstrapped with Create React App.
Getting started
- Fork the mobx-react-form-hoc repository on Github
- Clone your fork to your local machine
git clone git@github.com:<yourname>/mobx-react-form-hoc.git - Create a branch
git checkout -b my-topic-branch - Make your changes and add tests for them, lint, test then push to to github with
git push --set-upstream origin my-topic-branch. - Visit github and make your pull request.
Scripts
- Install
npm installoryarn install - Start developing
npm startoryarn start - Test
npm testoryarn test - Build
npm run buildoryarn build - Publish
npm run publishoryarn publish
License
MIT © Simon Mollweide