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

React-intl, Redux-Form combine and raise warnings

本文关键字:警告 并发 组合 Redux-Form React-intl      更新时间:2023-09-26

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

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);

我两个都需要,所以我把它们合并成一个导出,比如

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 redux-form@6.0.0-rc.3

由于Redux-Form的基础结构发生了重大变化,您还需要改变使用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/