Loëck Vézien
7 years ago
6 changed files with 109 additions and 38 deletions
@ -0,0 +1,38 @@ |
|||
// @flow
|
|||
|
|||
import { PureComponent } from 'react' |
|||
|
|||
type Props = { |
|||
children: any, |
|||
} |
|||
|
|||
type State = { |
|||
show: boolean, |
|||
} |
|||
|
|||
class Defer extends PureComponent<Props, State> { |
|||
state = { |
|||
show: false, |
|||
} |
|||
|
|||
componentDidMount() { |
|||
window.requestAnimationFrame(() => |
|||
this.setState({ |
|||
show: true, |
|||
}), |
|||
) |
|||
} |
|||
|
|||
render() { |
|||
const { children } = this.props |
|||
const { show } = this.state |
|||
|
|||
if (show) { |
|||
return children |
|||
} |
|||
|
|||
return null |
|||
} |
|||
} |
|||
|
|||
export default Defer |
Loading…
Reference in new issue