Tencent / Tencent/tdesign-react

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

Open
#2,455 2 comments 0 reactions 1 assignee View on GitHub

@honkinglin is already working on this.

Since Aug 20, 2023.

💪🏻 enhancement
Dominant language
TypeScript
Stars
965
Forks
373
Avg merge
3d 6h
Merged PRs (30d)
17

Description

这个功能解决了什么问题

使用 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};
`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.