ant-design/ant-design-mobile

开放 useConfig 给用户/开发者

Closed this issue · 0 comments

Version of antd-mobile

5.33.2

What is this feature about?

有些时候我们想在自己拓展的组件中用 cancel 和 ok 这样的通用文案,这时候我们只能自己写本地化逻辑,判断语言环境,加载对应的字符串。而如果 antd-mobile 能将内部使用的 useConfig 钩子开放给外部开发者使用,则会大大简化这种场景所需要的代码:

function MyButton() {
  const { locale } = useConfig();
  return <Button>{locale.common.cancel}</Button>
}