Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

message updating with key ,但是不能手动移除了 #19950

Closed
1 task
czbczb opened this issue Nov 26, 2019 · 9 comments · Fixed by #19967
Closed
1 task

message updating with key ,但是不能手动移除了 #19950

czbczb opened this issue Nov 26, 2019 · 9 comments · Fixed by #19967
Assignees

Comments

@czbczb
Copy link

czbczb commented Nov 26, 2019

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

let loadingKey = 'loading'
let hideLoading = message.loading({content: '正在加载数据...', key: loadingKey, duration: 0})
hideLoading() // not work

What is expected?

不需要自动移除,我需要调用hideloading方法手动移除message

What is actually happening?

duration:0
此时无法移除,
duration不为0时,antd设置默认3秒后会移除

Environment Info
antd 3.25.3
React 16.9.0
System 1
Browser Google Chrome 已是最新版本 版本 78.0.3904.108(正式版本) (64 位)
@yoyo837
Copy link
Contributor

yoyo837 commented Nov 26, 2019

ref: #18678 @wendzhue

@czbczb
Copy link
Author

czbczb commented Nov 27, 2019

您好,我看过这个issues,我希望的是通过callback去移除message,不需要更新操作

@czbczb
Copy link
Author

czbczb commented Nov 27, 2019

能不能给个异步移除的例子呢 @yoyo837

@wzhudev
Copy link
Contributor

wzhudev commented Nov 27, 2019

@yoyo837 好的,我会处理这个

@yoyo837
Copy link
Contributor

yoyo837 commented Nov 27, 2019

@czbczb 再提供个旧版本时功能正常的在线demo。

@czbczb
Copy link
Author

czbczb commented Nov 27, 2019

@yoyo837
image
旧的,您看这个是可以的,https://ant.design/components/message-cn/

@wzhudev
Copy link
Contributor

wzhudev commented Nov 27, 2019

Reason:

const target = key++;
const closePromise = new Promise(resolve => {
const callback = () => {
if (typeof args.onClose === 'function') {
args.onClose();
}
return resolve(true);
};
getMessageInstance(instance => {
const iconNode = (
<Icon type={iconType} theme={iconType === 'loading' ? 'outlined' : 'filled'} />
);
const switchIconNode = iconType ? iconNode : '';
instance.notice({
key: args.key || target,

In L69 it should be

const target = args.key || key++

@Aemple
Copy link
Contributor

Aemple commented Nov 27, 2019

@yoyo837 这个问题可以交给我来处理吗?😀

@czbczb
Copy link
Author

czbczb commented Nov 27, 2019

thank u @yoyo837

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants