import React from 'react';
import PropTypes from "prop-types";

import loadingImage from './images/loading.gif';

export default class LoadingSpinner extends React.PureComponent {

    render() {
        const message = this.props.message ? <h3>{this.props.message}</h3> : '';
        const classes = this.props.optClass ?
            "page-loader " + this.props.optClass :
            "page-loader";
        return (
            <div className={classes}>
                {message}
                <img src={loadingImage} width="70px" alt="loading"/>
            </div>
        )
    }
}

LoadingSpinner.propTypes = {
    message: PropTypes.string.isRequired
};
