import React, { Fragment } from 'react';
import { message } from 'antd';

class RotateTarget extends React.Component {
    componentDidMount() {
        try{
            if(window.webkit) {
                window.webkit.messageHandlers.event.postMessage("ChartInterfaceOrientationMaskPortrait");
            }else if(window.android) {
                window.android.requestedOrientationLandscape();
            }
        }catch(e) {
            message.error(e);
        }
    }

    componentWillUnmount() {
        try{
            if(window.webkit) {
                window.webkit.messageHandlers.event.postMessage("ChartInterfaceOrientationMaskLandscapeRight");
            }else if(window.android) {
                window.android.requestedOrientationPortrait();
            }
        }catch(e) {
            message.error(e);
        }
    }

    render() {
        return <Fragment></Fragment>
    }
}

export default RotateTarget;