问题描述
我一直在尝试在我的 react-select
中使用 react-json-schema-form
组件,但第一次选择字段没有更新。
这是我得到的行为。
Behaviour video
代码:
const CustomSelect = function (props) {
return (
<Select
id="input"
className="basic-single"
classNamePrefix="select"
options={props.options.enumOptions}
placeholder={props.label}
isSearchable={true}
onChange={(e) => {
props.onChange(e.value);
if(props.schema.title === "WiFi model"){
console.log(e.value)
}
}}
></Select>
);
};
道具来自 RJSF,enumOptions 看起来像:
[{label: "3Com",value: "3Com"}
{label: "4G Systems",value: "4G Systems"}
{label: "7Links",value: "7Links"}
{label: "8devices",value: "8devices"}
{label: "ADB",value: "ADB"}
{label: "ADI Engineering",value: "ADI Engineering"}
{label: "ADSLR",value: "ADSLR"}
{label: "ALFA Network",value: "ALFA Network"}]
谁能告诉我我做错了什么?
家长 RJSF:
<Form
schema={schema}
widgets={widgets}
onSubmit={onSubmit}
formData={formData}
/>
那是父组件,我使用 react-select 作为自定义组件!
const widgets = {
SelectWidget: CustomSelect,};
供参考: https://react-jsonschema-form.readthedocs.io/en/latest/advanced-customization/custom-widgets-fields/
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)