Replies: 2 comments
-
太重了吧,本来是 classNames 套一层的事情,还要用 Set 和 Array 来回转。 |
Beta Was this translation helpful? Give feedback.
0 replies
-
结论:hooks 可以提供一下,但是不会去实现 classNames 的内容,这样比较重 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
背景
在 #40221 讨论中,对许多组件添加了语义化类名和样式名,为开发者增加了便利性,方便聚合管理。
后续针对
<ConfigProvider />
也添加了当个组件全局 classNames 配置。 ref: #43372问题 & 动机
观察 components/input/Input.tsx#L218-L228 提交, 对于组合 classNames 需要格外小心,给 antd 组件维护者带来了一些负担(至少我认为是这样)。比如针对遗漏的 pr #47076 (并且这个 pr 修复方式不是特别正确,也未提交测试用例。)
解决
也许有其他更好的方案🤔
添加一个自定义 hook
components/config-provider/hooks/useClasses.ts
最终使用
components/modal/Modal.tsx
components/input/Input.tsx
效果
demo.tsx
Beta Was this translation helpful? Give feedback.
All reactions