index.js 964 Bytes
Newer Older
zhanghaozhe committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import React, { Component } from 'react';
import './input.scss'

import classnames from 'classnames'

class Input extends Component {
    clearInput = () => {
        this.props.onChange('')
    }

    render() {
        let {type, placeholder} = this.props
        return (
            <div className='custom-input-wrapper'>
                <input
                    type={type}
                    className={classnames('custom-input')}
                    placeholder={placeholder}
zhanghaozhe committed
19 20
                    onChange={this.props.onChange}
                    value={this.props.value}
zhanghaozhe committed
21 22 23
                />
                <i
                    className={classnames('iconfont icondanseshixintubiao-3', {
zhanghaozhe committed
24
                        hide: this.props.value.length === 0
zhanghaozhe committed
25 26
                    })}
                    onClick={this.clearInput}
zhanghaozhe committed
27
                />
zhanghaozhe committed
28 29 30 31 32 33 34 35 36
            </div>
        );
    }
}


Input.defaultProps = {type: 'text', placeholder: ''}

export default Input;