import React, { PureComponent } from 'react'; import { Input, Icon } from 'antd'; import styles from './index.less'; export default class EditableItem extends PureComponent { state = { value: this.props.value, editable: false, }; handleChange = (e) => { const { value } = e.target; this.setState({ value }); } check = () => { this.setState({ editable: false }); if (this.props.onChange) { this.props.onChange(this.state.value); } } edit = () => { this.setState({ editable: true }); } render() { const { value, editable } = this.state; return (
{ editable ?
:
{value || ' '}
}
); } }