mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
9daa8f5d98
[web] rename all the JSX files to .jsx/.tsx GitOrigin-RevId: 82056ae47e017523722cf258dcc83c8a925a28f7
38 lines
702 B
JavaScript
38 lines
702 B
JavaScript
import { useTranslation } from 'react-i18next'
|
|
import Icon from './icon'
|
|
import { useEffect, useState } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
|
|
function LoadingSpinner({ delay = 0 }) {
|
|
const { t } = useTranslation()
|
|
|
|
const [show, setShow] = useState(false)
|
|
|
|
useEffect(() => {
|
|
const timer = window.setTimeout(() => {
|
|
setShow(true)
|
|
}, delay)
|
|
|
|
return () => {
|
|
window.clearTimeout(timer)
|
|
}
|
|
}, [delay])
|
|
|
|
if (!show) {
|
|
return null
|
|
}
|
|
|
|
return (
|
|
<div className="loading">
|
|
<Icon type="refresh" fw spin />
|
|
|
|
{t('loading')}…
|
|
</div>
|
|
)
|
|
}
|
|
|
|
LoadingSpinner.propTypes = {
|
|
delay: PropTypes.number,
|
|
}
|
|
|
|
export default LoadingSpinner
|