mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-25 05:03:10 +08:00
28 lines
512 B
JavaScript
28 lines
512 B
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
export default class DelayedRender extends Component {
|
|
static propTypes = {
|
|
children: PropTypes.node.isRequired,
|
|
};
|
|
state = {
|
|
show: false,
|
|
};
|
|
|
|
componentDidMount() {
|
|
this.showTO = setTimeout(() => {
|
|
this.setState({
|
|
show: true,
|
|
});
|
|
}, 1000);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
clearTimeout(this.showTO);
|
|
}
|
|
|
|
render() {
|
|
return this.state.show ? this.props.children : <div />;
|
|
}
|
|
}
|