mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 07:16:36 +01:00
a75949e62c
`PropTypes.oneOf` was used accidentally instead of `PropTypes.oneOfType`. `oneOf` expects literal values, not types.
47 lines
1.0 KiB
JavaScript
47 lines
1.0 KiB
JavaScript
import React, { Component, isValidElement } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import Spinner from '../spinner'
|
|
|
|
class LoadingScreen extends Component {
|
|
static defaultProps = {
|
|
loadingMessage: null,
|
|
showLoadingSpinner: true,
|
|
}
|
|
|
|
static propTypes = {
|
|
loadingMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
showLoadingSpinner: PropTypes.bool,
|
|
header: PropTypes.element,
|
|
}
|
|
|
|
renderMessage() {
|
|
const { loadingMessage } = this.props
|
|
|
|
if (!loadingMessage) {
|
|
return null
|
|
}
|
|
|
|
return isValidElement(loadingMessage) ? (
|
|
loadingMessage
|
|
) : (
|
|
<span>{loadingMessage}</span>
|
|
)
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className="loading-overlay">
|
|
{this.props.header}
|
|
<div className="loading-overlay__container">
|
|
{this.props.showLoadingSpinner && (
|
|
<Spinner color="#F7C06C" className="loading-overlay__spinner" />
|
|
)}
|
|
{this.renderMessage()}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default LoadingScreen
|