change Modal.destroy to Modal.destroyAll

This commit is contained in:
tom 2018-12-03 21:49:00 +08:00 committed by 偏右
parent d9e0b33dbe
commit 00109a0698
6 changed files with 13 additions and 13 deletions

View File

@ -108,7 +108,7 @@ export default class Modal extends React.Component<ModalProps, {}> {
static warn: ModalFunc;
static warning: ModalFunc;
static confirm: ModalFunc;
static destroy: () => void;
static destroyAll: () => void;
static defaultProps = {
width: 520,

View File

@ -144,7 +144,7 @@ describe('Modal.confirm triggers callbacks correctly', () => {
jest.useRealTimers();
});
it('could be Modal.destroy', () => {
it('could be Modal.destroyAll', () => {
jest.useFakeTimers();
['info', 'success', 'warning', 'error'].forEach((type) => {
Modal[type]({
@ -153,7 +153,7 @@ describe('Modal.confirm triggers callbacks correctly', () => {
});
expect($$(`.ant-modal-confirm-${type}`)).toHaveLength(1);
});
Modal.destroy();
Modal.destroyAll();
['info', 'success', 'warning', 'error'].forEach((type) => {
jest.runAllTimers();
expect($$(`.ant-modal-confirm-${type}`)).toHaveLength(0);

View File

@ -7,11 +7,11 @@ title:
## zh-CN
使用 `Modal.destroy()` 可以销毁弹出的确认窗。通常用于路由监听当中,处理路由前进、后退不能销毁确认对话框的问题。
使用 `Modal.destroyAll()` 可以销毁弹出的确认窗。通常用于路由监听当中,处理路由前进、后退不能销毁确认对话框的问题。
## en-US
`Modal.destroy()` could destroy all confirmation modal dialogs. Usually, you can use it in router change event to destroy confirm modal dialog automatically
`Modal.destroyAll()` could destroy all confirmation modal dialogs. Usually, you can use it in router change event to destroy confirm modal dialog automatically
```jsx
import { Modal, Button } from 'antd';
@ -19,7 +19,7 @@ import { browserHistory } from 'react-router';
// router change
browserHistory.listen(() => {
Modal.destroy();
Modal.destroyAll();
});
const confirm = Modal.confirm;

View File

@ -100,15 +100,15 @@ modal.destroy();
}
</style>
- `Modal.destroy`
- `Modal.destroyAll`
`Modal.destroy()` could destroy all confirmation modal dialogs(Modal.info/Modal.success/Modal.error/Modal.warning/Modal.confirm). Usually, you can use it in router change event to destroy confirm modal dialog automatically without use modal reference to close( it's too complex to use for all modal dialogs)
`Modal.destroyAll()` could destroy all confirmation modal dialogs(Modal.info/Modal.success/Modal.error/Modal.warning/Modal.confirm). Usually, you can use it in router change event to destroy confirm modal dialog automatically without use modal reference to close( it's too complex to use for all modal dialogs)
```jsx
import { browserHistory } from 'react-router';
// router change
browserHistory.listen(() => {
Modal.destroy();
Modal.destroyAll();
});
```

View File

@ -53,7 +53,7 @@ Modal.confirm = function(props: ModalFuncProps) {
return confirm(config);
};
Modal.destroy = function () {
Modal.destroyAll = function () {
while (destroyFns.length) {
const close = destroyFns.pop();
if (close) {

View File

@ -98,15 +98,15 @@ modal.destroy();
}
</style>
- `Modal.destroy`
- `Modal.destroyAll`
使用 `Modal.destroy()` 可以销毁弹出的确认窗(即上述的 Modal.info、Modal.success、Modal.error、Modal.warning、Modal.confirm。通常用于路由监听当中处理路由前进、后退不能销毁确认对话框的问题而不用各处去使用实例的返回值进行关闭modal.destroy() 适用于主动关闭,而不是路由这样被动关闭)
使用 `Modal.destroyAll()` 可以销毁弹出的确认窗(即上述的 Modal.info、Modal.success、Modal.error、Modal.warning、Modal.confirm。通常用于路由监听当中处理路由前进、后退不能销毁确认对话框的问题而不用各处去使用实例的返回值进行关闭modal.destroy() 适用于主动关闭,而不是路由这样被动关闭)
```jsx
import { browserHistory } from 'react-router';
// router change
browserHistory.listen(() => {
Modal.destroy();
Modal.destroyAll();
});
```