This commit is contained in:
Maxime Renou 2019-03-01 14:55:16 +01:00
parent c274761818
commit 9c48ae47ca
5 changed files with 36 additions and 13 deletions

13
dist/index.es.js vendored
View File

@ -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(
FormTranslationConsumer,
null,
function (translator) {
return React.createElement(
'p',
{ className: 'alert alert-danger' },
this.state.data.error
translator.renderText(_this2.state.data.error)
);
}
);
}

File diff suppressed because one or more lines are too long

13
dist/index.js vendored
View File

@ -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(
FormTranslationConsumer,
null,
function (translator) {
return React__default.createElement(
'p',
{ className: 'alert alert-danger' },
this.state.data.error
translator.renderText(_this2.state.data.error)
);
}
);
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -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>
)
}