1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 07:16:36 +01:00
metamask-extension/ui/app/components/ui/loading-screen/loading-screen.component.js
Mark Stacey a75949e62c
Fix broken LoadingScreen PropType declaration (#9877)
`PropTypes.oneOf` was used accidentally instead of
`PropTypes.oneOfType`. `oneOf` expects literal values, not types.
2020-11-13 14:52:48 -03:30

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