javascript - React-intl、Redux-Form 结合并发出警告

标签 javascript reactjs redux

我现在尝试使用 React 和 Redux。我现在正在制作 i18n 应用程序,所以我必须在这个项目中使用 React-intl 包。
现在我的登录表单是这样的。导入如下。

import React, {
  Component
} from 'react';
import {
  reduxForm
} from 'redux-form';
import {
  injectIntl
} from 'react-intl';

现在,我想使用 intl.formatMessage 所以我必须在这个组件中使用 injectIntl​​ 就像

export default injectIntl(LoginForm);

现在我没有收到任何错误。
另外,我想在我的登录名表单和电子邮件表单中使用 Redux-form。喜欢

export default reduxForm({
  form: 'loginForm',
  fields: ['name', 'password']
})(LoginForm);

我需要两者,所以我将它们合并为 1 个导出,例如

export default reduxForm({
  form: 'entrance',
  fields: ['name', 'password']
})(injectIntl(LoginForm));

export default injectIntl(reduxForm({
  form: 'entrance',
  fields: ['name', 'password']
})(LoginForm));

但是以上两种类型我都收到警告

warning.js:44Warning: Unknown props `initialValue`, `autofill`, `onUpdate`, `valid`, `invalid`, `dirty`, `pristine`, `active`, `touched`, `visited`, `autofilled` on <input> tag. Remove these props from the element. For details, see "abbred"
in input (created by TextField)
in div (created by TextField)
in TextField (created by Entrance)
in div (created by CardText)
...

我可以将它们与此警告一起使用,但我想如何摆脱此警告。
我该怎么办?

最佳答案

您需要将 Redux-Form 更新到 v6 来克服这些错误(假设您正在运行 React v15.2.0+)。运行:

npm install --save <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="64160100111c49020b160924524a544a544916074a57" rel="noreferrer noopener nofollow">[email protected]</a>

由于基础设施发生重大变化,您还需要更改 Redux-Form 的使用方式。看看这里的文档: http://redux-form.com/6.0.0-rc.3/docs/MigrationGuide.md/

此外,本教程还提供了代码示例,演示了 Redux-Form v6 设置的外观:http://davidmeents.com/create-redux-form-validation-initialized-values/

关于javascript - React-intl、Redux-Form 结合并发出警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38901523/

相关文章:

javascript - RxJS 和 React 多次点击元素形成单个数据数组

javascript - 未调用 Redux reducer

TypeScript:如何键入返回函数的返回类型

php - 评估 php 生成的 javascript "inline"?

reactjs - 如何模拟 react 自定义钩子(Hook)返回值?

javascript - 隐藏元素直到加载完成(ng-cloak 不是我需要的)

javascript - React export 声明语句预期

javascript - redux如何管理store中的大数据?

javascript - jQuery 表单中的 .change 函数问题

javascript - 如何通过点击广告在新窗口中打开链接?