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

fix: dialog.show method return close function #740

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

itaober
Copy link
Contributor

@itaober itaober commented Jul 26, 2024

问题

Dialog.show 方法调用返回的 destory 方法固定为 noop,不能按照预期行为工作:
image

原因

调用 Dialog.show 时,return 的执行会优先于 TempDialog 组件中方法的执行。原 destory 为基础类型,无法在调用时获取到最新的期望内容。

修复方式

Map 存储 id-close 方法键值对,因为 Map 是引用类型,故在使用方调用时,能根据 id 拿到最新且对应的销毁方法。
其中 id 为 rv-dialog-root--${Date.now()},实际业务中可保证基本唯一。

具体代码见 PR。

Copy link

PR preview has been successfully built and deployed to https://react-vant-pr-740.surge.sh.

@3lang3 3lang3 merged commit cfc9f55 into 3lang3:main Jul 27, 2024
4 checks passed
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 this pull request may close these issues.

2 participants