accounts-frontend/packages/app/components/ui/form/FormInputComponent.tsx

27 lines
610 B
TypeScript
Raw Normal View History

import React from 'react';
2019-12-07 16:58:52 +05:30
import { MessageDescriptor } from 'react-intl';
import FormComponent from './FormComponent';
import FormError from './FormError';
2019-12-08 03:23:22 +05:30
import { ValidationError } from './FormModel';
2019-12-08 03:23:22 +05:30
type Error = ValidationError | MessageDescriptor;
2019-12-07 16:58:52 +05:30
export default class FormInputComponent<P, S = {}> extends FormComponent<
2020-05-24 04:38:24 +05:30
P & {
error?: Error;
},
S & {
error?: Error;
}
> {
2020-05-24 04:38:24 +05:30
renderError() {
return <FormError error={this.state?.error || this.props.error} />;
2020-05-24 04:38:24 +05:30
}
2020-05-24 04:38:24 +05:30
setError(error: Error) {
// @ts-ignore
this.setState({ error });
}
}