import _ from 'lodash'; import React from 'react'; import { Col, Row } from 'antd'; const defaultErrorMsg = "An error has occurred"; export default class ErrorMessage extends React.Component { constructor(props) { super(props); this.hideMessage = this.hideMessage.bind(this); this.state = { visible: true }; } componentWillReceiveProps(newProps) { if (!_.isEmpty(newProps.message)) { this.setState({ visible :true }); } } hideMessage() { this.setState({ visible: false }); } render() { return !this.state.visible ? null : (
{this.props.message || defaultErrorMsg}
Dismiss X
); } }