import React from 'react';
import _ from 'lodash';

import { Message } from 'semantic-ui-react'

class Messages extends React.Component {
    render() {
        let messages = this.props.messages ? (_.isArray(this.props.messages) ? this.props.messages : [this.props.messages]) : [];
        return messages.length > 0 ? (
            <Message floating negative>
                {messages.map((message, index) => <div key={index}>{message.msg}</div>)}
            </Message>
        ) : null;
    }
}

export default Messages;
