2018-01-13 20:54:49 +01:00
|
|
|
import React, { Component } from 'react';
|
2018-01-04 14:53:30 -08:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
2018-01-13 20:54:49 +01:00
|
|
|
export default class DelayedRender extends Component {
|
2018-01-04 14:53:30 -08:00
|
|
|
static propTypes = {
|
|
|
|
children: PropTypes.node.isRequired,
|
|
|
|
};
|
2018-08-05 17:57:17 +02:00
|
|
|
|
2018-01-04 14:53:30 -08:00
|
|
|
state = {
|
|
|
|
show: false,
|
|
|
|
};
|
2018-01-13 20:54:49 +01:00
|
|
|
|
2018-01-04 14:53:30 -08:00
|
|
|
componentDidMount() {
|
2018-03-31 04:54:59 +03:00
|
|
|
this.showTO = setTimeout(() => {
|
2018-01-04 14:53:30 -08:00
|
|
|
this.setState({
|
|
|
|
show: true,
|
|
|
|
});
|
|
|
|
}, 1000);
|
|
|
|
}
|
2018-03-31 04:54:59 +03:00
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
clearTimeout(this.showTO);
|
|
|
|
}
|
|
|
|
|
2018-01-04 14:53:30 -08:00
|
|
|
render() {
|
2018-08-05 17:57:17 +02:00
|
|
|
const { show } = this.state;
|
|
|
|
const { children } = this.props;
|
|
|
|
return show ? children : <div />;
|
2018-01-04 14:53:30 -08:00
|
|
|
}
|
|
|
|
}
|