Javascript 为“日历”提供的“字符串”类型的“选定”属性无效,应为“日期”实例?
我在react js中使用日期选择器 但是我的当前值为空Javascript 为“日历”提供的“字符串”类型的“选定”属性无效,应为“日期”实例?,javascript,reactjs,redux,datepicker,Javascript,Reactjs,Redux,Datepicker,我在react js中使用日期选择器 但是我的当前值为空null。现在我想在我聚焦到输入字段时显示日期选择器。但我收到错误/警告,这是为什么 proxyConsole.js:72 Warning: Failed prop type: Invalid prop `selected` of type `String` supplied to `Calendar`, expected instance of `Date`. in Calendar (created by OnClickOuts
null
。现在我想在我聚焦到输入字段时显示日期选择器。但我收到错误/警告,这是为什么
proxyConsole.js:72 Warning: Failed prop type: Invalid prop `selected` of type `String` supplied to `Calendar`, expected instance of `Date`.
in Calendar (created by OnClickOutside(Calendar))
in OnClickOutside(Calendar) (created by DatePicker)
in div (created by InnerPopper)
in InnerPopper (created by Context.Consumer)
in Popper (created by PopperComponent)
in Manager (created by PopperComponent)
in PopperComponent (created by DatePicker)
in DatePicker (created by Main)
实际上,我在转换数据时添加了一个条件
data[i].displaytext = i;
if (data[i].dataType === "DATE" && data[i].value) {
data[i].value = new Date(data[i].value);
}
obj[lastLabel] = [...obj[lastLabel], data[i]];
}
这是我的密码
请帮助我删除此警告它看起来像DOB
对象中的默认值
是一个字符串,但您将其传递给的组件需要一个日期
。看起来好像变了
DOB: {
value: "",
type: "FIELD",
editable: true,
dataType: "DATE",
required: true,
displayName: null,
pattern: null
}
到
DOB:{
值:null//
DOB: {
value: null, // <- specifically this line
type: "FIELD",
editable: true,
dataType: "DATE",
required: true,
displayName: null,
pattern: null
}