import React, {Component} from 'react';
import FormContext from './FormContext';
import {toast, ToastContainer} from 'react-toastify';
import FormTranslationContext, {FormTranslationConsumer} from './FormTranslationContext'
class ContextAwareForm extends Component
{
constructor(props) {
super(props)
this.state = {
data: props.data
}
this.displayError = true
this.handleError(props)
}
componentWillReceiveProps(props)
{
this.handleError(props)
this.setState({
data: props.data
})
}
handleError(props)
{
if (props.data && props.data.error && props.toast && this.displayError == true) {
toast.error(this.props.translator.renderText(props.data.error))
this.displayError = false
}
}
render()
{
return (
{this.props.translator.renderText(this.state.data.error)}
) } return null } } export default class Form extends Component { render() { return (