@modul/mobx-form

1.0.24 • Public • Published

@modul/mobx-form

Пример:

import React from 'react';
import BaseForm, {TextareaField} from 'common-mobx-form';

const fields = ['text'];
const isRequired = message => ({field}) => {
  const isValid = !!field.value;
  return [isValid, message];
};
const validators = {comment: [isRequired('Обязательное поле')]};

class MobxText extends React.Component {
  constructor(props) {
    super(props);
    this.form = new BaseForm({fields, validators}, {
      hooks: {
        onSuccess() { console.log('ok') },
        onError() {console.log('error') }},
    });
  }
  render() {
      <TextareaField field={this.form.$('text')}/>
    );
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @modul/mobx-form

Weekly Downloads

0

Version

1.0.24

License

ISC

Unpacked Size

120 kB

Total Files

29

Last publish

Collaborators

  • benderr
  • lazio_dev
  • aleksandrovvs
  • kamaeviv
  • anniktar
  • modul-frontend