mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Create app namespace for all absolute requires of app modules. Move all packages under packages yarn workspace
This commit is contained in:
35
packages/app/components/ui/form/FormInputComponent.tsx
Normal file
35
packages/app/components/ui/form/FormInputComponent.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
import { MessageDescriptor } from 'react-intl';
|
||||
|
||||
import FormComponent from './FormComponent';
|
||||
import FormError from './FormError';
|
||||
|
||||
type Error = string | MessageDescriptor;
|
||||
|
||||
export default class FormInputComponent<P, S = {}> extends FormComponent<
|
||||
P & {
|
||||
error?: Error;
|
||||
},
|
||||
S & {
|
||||
error?: Error;
|
||||
}
|
||||
> {
|
||||
componentWillReceiveProps() {
|
||||
if (this.state && this.state.error) {
|
||||
Reflect.deleteProperty(this.state, 'error');
|
||||
|
||||
this.setState(this.state);
|
||||
}
|
||||
}
|
||||
|
||||
renderError() {
|
||||
const error = (this.state && this.state.error) || this.props.error;
|
||||
|
||||
return <FormError error={error} />;
|
||||
}
|
||||
|
||||
setError(error: Error) {
|
||||
// @ts-ignore
|
||||
this.setState({ error });
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user