gpt4 book ai didi

reactjs - 使用react-i18next和ant design Form

转载 作者:行者123 更新时间:2023-12-03 14:31:28 25 4
gpt4 key购买 nike

使用react-18next我必须像这样包装组件

export default translate(['common', 'user', 'validation'], {wait: true})(MyComponent);

但是antdesign表单已经包裹了组件 https://ant.design/components/form/

const WrappedNormalLoginForm = Form.create()(NormalLoginForm);

ReactDOM.render(<WrappedNormalLoginForm />, mountNode);

所以我想将react-18next与antdesign表单一起使用,我确实喜欢这样

export default translate(['common', 'user', 'validation'], {wait: true})(Form.create()(LoginForm));

我收到了这个错误( typescript )

TS2559: Type '{ onSubmit: (username: any, password: any) => void; clearError: () => void; isProcessing: ...' has no properties in common with type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<Pick<any, never>, never> & Translat...'.

LoginForm.ts

interface Props {
onSubmit(username, password);
clearError;
isProcessing;
form;
error;
t?;
}

class LoginForm extends React.Component<Props, any> {}

你能帮我解决这个问题吗?非常感谢!

最佳答案

您可以使用recompose包。

https://github.com/acdlite/recompose

然后做这样的事情:

import { compose} from 'recompose'

{...}

export default compose(translate(['common', 'user', 'validation'], {wait: true}))(Form.create()(LoginForm));

关于reactjs - 使用react-i18next和ant design Form,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51829159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com