insomnia/app/ui/components/base/Lazy.js
Gregory Schier bce0e5fec1 Fixed some editor bugs (#97)
* Fixed some editor bugs

* Some fixes

* Update index.js
2017-02-28 16:10:23 -08:00

24 lines
448 B
JavaScript

import React, {PureComponent, PropTypes} from 'react';
class Lazy extends PureComponent {
constructor (props) {
super(props);
this.state = {show: false};
}
componentDidMount () {
const delay = this.props.delay || 0;
setTimeout(() => this.setState({show: true}), delay);
}
render () {
return this.state.show ? this.props.children : null;
}
}
Lazy.propTypes = {
delay: PropTypes.number,
};
export default Lazy;