index.js 746 Bytes
Newer Older
zhanghaozhe committed
1
import React, { PureComponent } from 'react';
zhanghaozhe committed
2 3

export default function (WrappedComponent) {
zhanghaozhe committed
4
    return class extends PureComponent {
zhanghaozhe committed
5
        componentDidMount() {
zhanghaozhe committed
6 7 8
            document.body.style.height = `${window.innerHeight}px`
            document.getElementById('root').style.height = `${window.innerHeight}px`
            document.documentElement.style.height = `${window.innerHeight}px`
zhanghaozhe committed
9 10 11 12
        }
        componentWillUnmount() {
            document.body.style.height = `auto`
            document.getElementById('root').style.height = `auto`
zhanghaozhe committed
13
            document.documentElement.style.height = 'auto'
zhanghaozhe committed
14 15 16 17 18 19 20 21 22 23
        }

        render() {
            return (
                <WrappedComponent {...this.props}/>
            );
        }
    }
}