Hello
This commit is contained in:
parent
c274761818
commit
9c48ae47ca
|
@ -2801,7 +2801,8 @@ var Form = function (_Component) {
|
|||
key: 'handleError',
|
||||
value: function handleError(props) {
|
||||
if (props.data && props.data.error && props.toast && this.displayError == true) {
|
||||
lib_8.error(props.data.error);
|
||||
var contextValue = useContext(FormTranslationContext);
|
||||
lib_8.error(contextValue.renderText(props.data.error));
|
||||
this.displayError = false;
|
||||
}
|
||||
}
|
||||
|
@ -2823,11 +2824,19 @@ var Form = function (_Component) {
|
|||
}, {
|
||||
key: 'renderError',
|
||||
value: function renderError() {
|
||||
var _this2 = this;
|
||||
|
||||
if (this.state.data && this.state.data.error && !this.props.toast) {
|
||||
return React.createElement(
|
||||
'p',
|
||||
{ className: 'alert alert-danger' },
|
||||
this.state.data.error
|
||||
FormTranslationConsumer,
|
||||
null,
|
||||
function (translator) {
|
||||
return React.createElement(
|
||||
'p',
|
||||
{ className: 'alert alert-danger' },
|
||||
translator.renderText(_this2.state.data.error)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2808,7 +2808,8 @@ var Form = function (_Component) {
|
|||
key: 'handleError',
|
||||
value: function handleError(props) {
|
||||
if (props.data && props.data.error && props.toast && this.displayError == true) {
|
||||
lib_8.error(props.data.error);
|
||||
var contextValue = useContext(FormTranslationContext);
|
||||
lib_8.error(contextValue.renderText(props.data.error));
|
||||
this.displayError = false;
|
||||
}
|
||||
}
|
||||
|
@ -2830,11 +2831,19 @@ var Form = function (_Component) {
|
|||
}, {
|
||||
key: 'renderError',
|
||||
value: function renderError() {
|
||||
var _this2 = this;
|
||||
|
||||
if (this.state.data && this.state.data.error && !this.props.toast) {
|
||||
return React__default.createElement(
|
||||
'p',
|
||||
{ className: 'alert alert-danger' },
|
||||
this.state.data.error
|
||||
FormTranslationConsumer,
|
||||
null,
|
||||
function (translator) {
|
||||
return React__default.createElement(
|
||||
'p',
|
||||
{ className: 'alert alert-danger' },
|
||||
translator.renderText(_this2.state.data.error)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
11
src/Form.js
11
src/Form.js
|
@ -1,7 +1,7 @@
|
|||
import React, {Component} from 'react';
|
||||
import FormContext from './FormContext';
|
||||
import {toast, ToastContainer} from 'react-toastify';
|
||||
|
||||
import FormTranslationContext, {FormTranslationConsumer} from './FormTranslationContext'
|
||||
export default class Form extends Component
|
||||
{
|
||||
constructor(props) {
|
||||
|
@ -25,7 +25,8 @@ export default class Form extends Component
|
|||
handleError(props)
|
||||
{
|
||||
if (props.data && props.data.error && props.toast && this.displayError == true) {
|
||||
toast.error(props.data.error)
|
||||
const contextValue = useContext(FormTranslationContext);
|
||||
toast.error(contextValue.renderText(props.data.error))
|
||||
this.displayError = false
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +56,11 @@ export default class Form extends Component
|
|||
if (this.state.data && this.state.data.error && !this.props.toast)
|
||||
{
|
||||
return (
|
||||
<p className="alert alert-danger">{this.state.data.error}</p>
|
||||
<FormTranslationConsumer>
|
||||
{(translator) => (
|
||||
<p className="alert alert-danger">{translator.renderText(this.state.data.error)}</p>
|
||||
)}
|
||||
</FormTranslationConsumer>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue