import React, { Component } from 'react'; import { Icon, Input, Tooltip } from 'antd'; import PropTypes from 'prop-types'; import './Label.scss'; export default class Label extends Component { constructor(props) { super(props); this.state = { inputShow: false, inputValue: '' }; } static propTypes = { onChange: PropTypes.func, desc: PropTypes.string, cat_name: PropTypes.string }; toggle = () => { this.setState({ inputShow: !this.state.inputShow }); }; handleChange = event => { this.setState({ inputValue: event.target.value }); }; componentWillReceiveProps(nextProps) { if (this.props.desc === nextProps.desc) { this.setState({ inputShow: false }); } } render() { return (
{this.props.desc && (
{!this.state.inputShow ? (

{this.props.desc}   

) : (
{ this.props.onChange(this.state.inputValue); this.toggle(); }} type="check" />
)}
)}
); } }