2017-08-23 00:19:50 +05:30
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2016-05-02 14:50:50 +05:30
|
|
|
|
|
|
|
import FormComponent from './FormComponent';
|
2016-07-28 09:55:02 +05:30
|
|
|
import FormError from './FormError';
|
2016-05-02 14:50:50 +05:30
|
|
|
|
|
|
|
export default class FormInputComponent extends FormComponent {
|
|
|
|
static displayName = 'FormInputComponent';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
error: PropTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
componentWillReceiveProps() {
|
|
|
|
if (this.state && this.state.error) {
|
|
|
|
Reflect.deleteProperty(this.state, 'error');
|
|
|
|
|
|
|
|
this.setState(this.state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setEl = (el) => {
|
|
|
|
this.el = el;
|
|
|
|
};
|
|
|
|
|
|
|
|
renderError() {
|
|
|
|
const error = this.state && this.state.error || this.props.error;
|
|
|
|
|
2016-07-28 09:55:02 +05:30
|
|
|
return <FormError error={error} />;
|
2016-05-02 14:50:50 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
setError(error) {
|
|
|
|
this.setState({error});
|
|
|
|
}
|
|
|
|
}
|