PhoneView.js 741 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
import React, { Fragment, PureComponent } from 'react';
import { Input } from 'antd';

class PhoneView extends PureComponent {
  render() {
    const { value, onChange } = this.props;
    let values = ['', ''];
    if (value) {
      values = value.split('-');
    }
    return (
      <Fragment>
        <Input
          value={values[0]}
          onChange={(e) => {
            onChange(`${e.target.value}-${values[1]}`);
          }}
          style={{ width: 128, marginRight: 8 }}
        />
        <Input
          onChange={(e) => {
            onChange(`${values[0]}-${e.target.value}`);
          }}
          value={values[1]}
          style={{ width: 312 }}
        />
      </Fragment>
    );
  }
}

export default PhoneView;