alibaba-fusion / next

🦍 A configurable component library for web built on React.
https://fusion.design
MIT License
4.58k stars 584 forks source link

[Dialog/ConfigProvider]Dialog.show() message.show() 无法获取其插入节点处的 context #3578

Open miadwang opened 2 years ago

miadwang commented 2 years ago

Component

Dialog

Reproduction link

https://riddle.alibaba-inc.com/riddles/4683412b

Steps to reproduce

点击show按钮,dialog无法弹出,控制台有报错

miadwang commented 2 years ago
Screen Shot 2021-12-01 at 11 13 44

使用configProvider配置popupContainer为root节点,节点所在位置有react-intl提供的context,但是组件无法获取到。 错误为:Error: [React Intl] Could not find required intl object. needs to exist in the component ancestry.

miadwang commented 2 years ago
A05014AA-EDD4-4408-91E4-C55AC0599E3D

FormattedMessage代码

miadwang commented 2 years ago

Antd的message和dialog组件提供一种配置方法获取context https://ant.design/components/modal-cn/

Screen Shot 2021-12-01 at 11 20 58
bindoon commented 2 years ago

比较像 ConfigProvider 的问题

YSMJ1994 commented 7 months ago

问题同 Antd 的原因一样,创建了新的 react 树来承载弹层内容,所以获取不到应用树的 context,需要新增类似 Antd 的 Model.useModel 的 api 来支持这一功能,预计在接下来的几个版本中支持