如何在antd表单中使用react-i18next和Namespaces

问题描述 投票:0回答:1

我是i18next中的新手打字稿,我希望使用withNamespaces翻译一个antd表单

export default withNamespaces()(Form.create()(MyComponent));

这给了我以下错误:

Argument of type 'ComponentClass<RcBaseFormProps & Pick<any, string | number | symbol>, any>' is not assignable to parameter of type 'ComponentType<WithNamespaces>'. Type 'ComponentClass<RcBaseFormProps & Pick<any, string | number | symbol>, any>' is not assignable to type 'ComponentClass<WithNamespaces, any>'. Type 'RcBaseFormProps & Pick<any, string | number | symbol>' is missing the following properties from type 'WithNamespaces': tReady, i18n, t

这样做的正确方法是什么?谢谢。

reactjs typescript antd i18next
1个回答
0
投票

如果有人有相同的问题可以使用recompose包。

https://github.com/acdlite/recompose

然后做这样的事情:

import { compose} from 'recompose'

{...}

export default compose(withNamespaces())(Form.create()(MyComponent))

© www.soinside.com 2019 - 2024. All rights reserved.