import * as React from 'react' ; import Progress , { LinearProgressProps as ProgressProps , } from '@material-ui/core/LinearProgress' ; import PropTypes from 'prop-types' ; import { makeStyles } from '@material-ui/core/styles' ; import classnames from 'classnames' ; import { useTimeout } from 'ra-core' ; const useStyles = makeStyles ( theme => ( { root : { margin : `${ theme . spacing ( 1 ) }px 0` , width : `${ theme . spacing ( 20 ) }px` , } , } ) , { name : 'RaLinearProgress' } ) ; see ReferenceField see ReferenceInput typedef Props prop { Object } classes prop { string } className prop { integer } timeout param { Props } props const LinearProgress = ( { timeout = 1000 , ... props } ) => { const { classes : classesOverride , className , ... rest } = props ; const classes = useStyles ( props ) ; const oneSecondHasPassed = useTimeout ( timeout ) ; return oneSecondHasPassed ? ( < Progress className = { classnames ( classes . root , className ) } { ... rest } />) : null; } ; LinearProgress . propTypes = { classes : PropTypes . object , className : PropTypes . string , timeout : PropTypes . number , } ; LinearProgress . displayName = 'LinearProgress' ; export interface LinearProgressProps extends ProgressProps { timeout ? : number ; } export default LinearProgress ;