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

[dialog] 增加useDialog 方法用于获取弹窗内容的上下问题 #2454

Closed
duxphp opened this issue Aug 20, 2023 · 3 comments
Closed

[dialog] 增加useDialog 方法用于获取弹窗内容的上下问题 #2454

duxphp opened this issue Aug 20, 2023 · 3 comments
Assignees

Comments

@duxphp
Copy link
Contributor

duxphp commented Aug 20, 2023

这个功能解决了什么问题

使用 DialogPlugin 将 body 设置为自定义组件后,该组件无法获取到调用组件的上下文

你建议的方案是什么

类似于 antd 的 useModal,通过自定义埋点使用DialogPlugin方法后内部的子组件可以获取到父级的上下文数据。

`

Modal.useModal()
当你需要使用 Context 时,可以通过 Modal.useModal 创建一个 contextHolder 插入子节点中。通过 hooks 创建的临时 Modal 将会得到 contextHolder 所在位置的所有上下文。创建的 modal 对象拥有与 Modal.method 相同的创建通知方法。

const [modal, contextHolder] = Modal.useModal();

React.useEffect(() => {
modal.confirm({
// ...
});
}, []);

return

{contextHolder}
;
`

@github-actions
Copy link
Contributor

👋 @duxphp,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@github-actions
Copy link
Contributor

♥️ 有劳 @ldwonday @psaren @huoyuhao @honkinglin 尽快确认问题。
确认有效后将下一步计划和可能需要的时间回复给 @duxphp

@uyarn
Copy link
Collaborator

uyarn commented Aug 21, 2023

duplicate of #2455

@uyarn uyarn closed this as completed Aug 21, 2023
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

No branches or pull requests

3 participants