Skip to content

Instantly share code, notes, and snippets.

@cigrainger
Created November 15, 2018 00:50
Show Gist options
  • Save cigrainger/e4a628da0db35b90e32264b85c695bca to your computer and use it in GitHub Desktop.
Save cigrainger/e4a628da0db35b90e32264b85c695bca to your computer and use it in GitHub Desktop.
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