import React, { useState } from 'react';
import * as ReactDOM from 'react-dom';
import LoginDialog from '../../../../modules/login/LoginDialog';

// 使用函数调用登录组件
export default function Login(props) {
  const div = document.createElement('div');
  document.body.appendChild(div);

  function destroy() {
    const unmountResult = ReactDOM.unmountComponentAtNode(div);
    if (unmountResult && div.parentNode) {
      div.parentNode.removeChild(div);
    }
  }

  function render() {
    setTimeout(() => {
      ReactDOM.render(
        <MyLoginDialog afterClose={destroy} />
        ,
        div,
      );
    });
  }

  render();
}

function MyLoginDialog({afterClose}) {
  const [isRender, setIsRender] = useState(true);
  return (
    <LoginDialog
      isRender={isRender}
      Modifyloginvalue={() => {setIsRender(false);afterClose()}}
    />
  )
}


