简体   繁体   English

React - 使用函数评估道具值时出错

[英]React - Error using function to evaluate prop value

In the picture below, I'm trying to replace line 120 (which works when not commented) with line 121 so that I can add additional logic in the function on line 98.在下图中,我尝试将第 120 行(未注释时有效)替换为第 121 行,以便我可以在第 98 行的函数中添加额外的逻辑。

However I am seeing error "Invalid value for prop value "但是我看到错误“道具value无效”

在此处输入图像描述

You are passing an arrow function rather than a value.您传递的是箭头函数而不是值。 It should be它应该是

value={this.getValue(data, name, catIndex, fieldIndex, type, value)}

Your getValue(1,2,3,4) function has 4 parameters.您的getValue(1,2,3,4)函数有 4 个参数。 But you called it with 6 parameters.但是你用 6 个参数调用它。

value={()=> this.getValue(data, name, catIndex, fieldIndex, type, value)}

PS... do not upload your code with picture. PS...不要上传您的代码与图片。 copy and paste is not difficult.复制和粘贴并不难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM