卸载时的操作
//即将卸载时的操作
<Prompt
message={(location) => {
if (resetModal) {
resetModal.destroy();
}
}}
/>
卸载完成后的操作
//卸载完成后的操作
useEffect(() => {
return componentDidUnmount;
}, []);
const componentDidUnmount = () => {
};
Demo案例
import { history, Prompt } from 'umi';
import React, { useState, useEffect, useRef } from 'react';
import { withRouter } from 'react-router';
import { Table, Popconfirm,Modal } from 'antd';
const Demo= (props) => {
const [resetModal, setResetModal] = useState();
useEffect(() => {
return componentDidUnmount;
}, []);
const componentDidUnmount = () => {
};
//重置密码弹窗
const resetPswModal = (title, psw, name) => {
let secondsToGo = 3;
let modalData = {
width: '320px',
className: 'pswModal',
okText: secondsToGo > 0 ? secondsToGo : '知道了',
okButtonProps: {
disab