为 antd 应用默认包裹 App 组件 #41122
Replies: 7 comments 10 replies
This comment has been hidden.
This comment has been hidden.
-
为什么 antd 的 ConfigProvider 不支持包含 App ? |
Beta Was this translation helpful? Give feedback.
-
建议ConfigProvider 做一个开关支持 ,不要让umi使用插件支持(这个支持脱离了组件完备性)。 |
Beta Was this translation helpful? Give feedback.
-
umi |
Beta Was this translation helpful? Give feedback.
-
升级了umi之后,使用: 为什么会找不到方法呢,有兄弟能解惑么? |
Beta Was this translation helpful? Give feedback.
-
@Wxh16144 请问在全局方法中怎么使用 |
Beta Was this translation helpful? Give feedback.
-
概括
Umi 框架默认使用 antd 提供的
<App />
组件包裹一层,以方便开发者直接使用 App.useApp` hook;动机
接到社区大量反馈,静态调用 message 方法,无法消费 Design Token 问题,故我们在
antd@5.2
提供了<App />
组件,期望开发者在应用最外层套一次, 然后通过App.useApp
得到 message,modal,notification 方法;但仍有部分开发者忘记使用
<App />
包裹应用。导致 useApp 获得的方法仍不生效。该讨论期望通过框架默认帮助开发者注入 Provider。
最终我们希望开发者使用
const { message } = useApp();
代替import message from ‘antd’;
, 我们也更推荐使用这种方式。详细
通过 umijs plugin 实现默认注入, 参考: https://github.com/umijs/umi/blob/03983e574b641be82c90928cdcc5bd484e3c82c7/packages/plugins/src/antd.ts
缺点
暂无
优点
开发者可以直接在业务中直接使用 App.useApp 得到静态 message,modal,notification 方法;
Beta Was this translation helpful? Give feedback.
All reactions