Created
November 15, 2018 00:50
-
-
Save cigrainger/e4a628da0db35b90e32264b85c695bca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PropTypes from "prop-types"; | |
import { PureComponent } from "react"; | |
class Delayed extends PureComponent { | |
constructor(props) { | |
super(props); | |
this.state = { hidden: true }; | |
} | |
componentDidMount() { | |
setTimeout(() => { | |
this.setState({ hidden: false }); | |
}, this.props.waitBeforeShow); | |
} | |
render() { | |
return this.state.hidden ? null : this.props.children; | |
} | |
} | |
Delayed.propTypes = { | |
waitBeforeShow: PropTypes.number.isRequired | |
}; | |
export default Delayed; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment