- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚将 Redux 添加到我的 React 应用程序中,我认为它可以正常工作,但现在我的控制台中不断出现两个错误。
这个:
Warning: Failed propType: Required prop 'fields' was not specified in 'ReduxForm(MyForm)'. Check the render method of 'Connect(ReduxForm(MyForm))'.
还有这个:
Uncaught TypeError: Cannot read property 'reduce' of undefined
第二个指的是这个(第2行):
var getValues = function getValues(fields, state) {
return fields.reduce(function (accumulator, field) {
getValue(field, state, accumulator);
return accumulator;
}, {});
};
更新/答案:确保 redux-form 是版本 6 或更高版本
最佳答案
授人以渔!
您还没有真正提供足够的代码来继续。
如果字段意外未定义,那么您应该在各处使用 chrome 调试器或 console.log 进行单步调试。这些都是被严重低估的方法!
您的代码将一直运行,直到在断点处停止,您可以从那里继续前进。如果您需要检查每一行,请在单步执行之前在所有行上添加断点。您可以右键单击变量以添加到监视列表。
继续下去,直到发现错误逻辑、未定义/空或出现错误。请注意,当代码在断点处暂停时,您可以随时从控制台使用 console.log() ,它将正确记录范围内的变量。
关于javascript - "Warning: Failed propType: Required prop ' 字段 ' was not specified in ' ReduxForm(MyForm) '",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40230660/
我使用 Redux 表单版本 6.8.0。 我有一个表单组件,它通过“mapStateToProps”函数获取“initialValues”。在第一次渲染时,一切都工作得很好。 按照我的表单配置: c
我正在使用 ReduxForm 和两种类型的表单: 模态框内 在标签内。 取决于表单的类型,我必须调整我的 reduxForm 'connect' 参数。 使用 Tab,我需要: 卸载时销毁 启用重新
我正在使用标准化器来转换来自将 api 转换为简单的日期(例如 2016-05-24)。我的标准化器如下所示: export const dateNormalizer = function(value
我试图按如下方式获取表单设置的初始值,但它不起作用: const mapStateToProps = (state, props) => ({ initialValues: state.chart
我在 redux-form 中制作了一些自定义表单,并且想知道如何清除单选按钮。我知道你可以拉下重置支柱,但我不确定这是否可以完成这项工作。我将用图片解释我所拥有的以及我想要它做什么。 我有一个表单,
我在 react-native 应用程序中有简单的表单组件。我使用类型脚本。在我的组件中,我有几个初始化字段和两个连接的操作。最后,我创建表单,然后连接操作和我的商店。不幸的是,这种组合不起作用。我收
我喜欢在表单安装后重新触发验证。假设我喜欢在每次单击名为“验证输入”的按钮时运行验证。 这该怎么做? 相关问题: How to run validation on a slice of a redux
我使用 reduxform 生成一个调查,其中包括一些单选按钮问题。问题是,每当我更改单选按钮的值时,都会收到此错误: Uncaught Error: Must access array elemen
我已经检查了具有初始化值的 reduxForm 示例代码,他们的代码和我的代码之间的唯一区别是以下代码块.. 我的代码 (不适用于初始值) function mapStateToProps(state
我有一个包含输入类型文件的 reduxForm,所选文件的返回值未定义我的代码是: renderFileField 函数是: renderFileField( field ){ return
我正在尝试使用 ReduxForm 进行一些单元测试,但我显然对像这样的最简单的单元测试有问题。 实际上,我有一个搜索栏,当我修改它的输入时,我需要状态来反射(reflect)该数据。 我写了这个测试
我有一个相当复杂的多级深层/嵌套形式,使用 reduxForm() 连接到 React/Redux 。由于表单非常大,我已将其部分分解为子组件。其中一些组件需要访问 Redux 状态,因此需要通过 p
在我的表单中,我通过以下代码传递初始值。 function mapStateToProps(state) { return { initialValues: {
我在reduxForm中浏览了一段简单的代码。什么是原始和顺服?这些的目的是什么? 最佳答案 pristine 表示表单中的任何字段尚未修改。也许您无法在文档中找到它的确切定义,但 Angular 中
我有一个 Redux Form 组件,其中有一个名为 PlotMap 的 Google Maps 子组件。子组件将 map 输入作为回调中的对象传递回。我想在提交时将此 map 输入对象包含在表单数据
我正在尝试获取使用 v6 redux-form 创建的表单,以在我的应用程序组件中呈现以在浏览器中显示。但是,我收到以下错误: Uncaught Error: `mapDispatchToProps`
我最近弹出了 create-react-app,并且收到了 ReduxForm 的错误,该错误阻止了 webpack 编译。这是错误:“错误‘NewComplaintModal’是一个没有类分配的类”
我正在尝试将 redux-form 插入到我的项目中,但出现此错误。有没有人知道是什么问题。 到目前为止,我得出的结论是,当我添加以下代码时,它开始向我返回此错误-“未捕获的 TypeError:无法
这种有点的工作原理,除了当我进行 service_type 单选选择时附加 block 不会显示,它仅在我完成附加操作(例如添加或删除)时才会弹出/重新呈现服务 block 或更改另一个字段。
我正在从 Redux 形式迁移到 React 最终形式。是否有 react-final-form 中 ReduxForm 的 FormSection 的替代品? 我看到了一个解决方案here通过使用点
我是一名优秀的程序员,十分优秀!