Fix field errors view (fixes #23) (#29)

* Probably fixes #23

* Track field errors from state only

The previous commit has moved error storage to state so it isn't
necessary to check for error in props anymore.

* Undo state initialization from props
This commit is contained in:
kotwys 2020-08-05 15:58:31 +04:00 committed by GitHub
parent 74f04e9080
commit 4265b37543
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,18 +15,8 @@ export default class FormInputComponent<P, S = {}> extends FormComponent<
error?: Error; error?: Error;
} }
> { > {
componentDidUpdate() {
if (this.state && this.state.error) {
this.setState({
error: undefined,
});
}
}
renderError() { renderError() {
const error = (this.state && this.state.error) || this.props.error; return <FormError error={this.state?.error || this.props.error} />;
return <FormError error={error} />;
} }
setError(error: Error) { setError(error: Error) {