react-input-interceptor

1.1.1 • Public • Published

react-input-interceptor

React Input component data parse and format.

How to use?

Install

> npm install react-input-interceptor

Example(based on antd)

import React, { Component } from 'react';
import { Form, Input } from 'antd';
import InputInterceptor from 'react-input-interceptor'
 
@Form.create()
class Example extends Component {
  // view => model
  handleParse = (value) => {
    // do something
  }
 
  // model => view
  handleFormat = (value) => {
    // do something
  }
 
  render() {
    const { form } = this.props;
    const { getFieldDecorator } = form;
 
    return (
      <div>
        {
          getFieldDecorator('field')(
            <InputInterceptor parse={this.handleParse} format={this.handleFormat}>
              <Input />
            </InputInterceptor>
          )
        }
      </div>
    )
  }
}

Readme

Keywords

Package Sidebar

Install

npm i react-input-interceptor

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

11.5 kB

Total Files

6

Last publish

Collaborators

  • jackycoder