react-json-schema-form-extras
react-json-schema-form-extras copied to clipboard
typeahead: how to set initial value
Hi all,
I'm opening a modal and passing an item to edit in react-jsonschema-form. Sometimes a value for the typeahead comes, sometimes not. When there is no initial value, the typeahead works fine. It shows options and allows to choose one. I pass a function to mapping to return id instead of the string that was chosen:
'compania': {
"ui:field": "typeahead",
typeahead: {
id: "compania_typeahead",
options: proveedores.map(x => x.nombre),
mapping: (event) => {
const sel = proveedores.find(x => x.nombre === event);
return sel.proveedor;
},
}
However, when some value comes for the typeahead field as an initial value, I get this error in the console:
Warning: Failed prop type: Invalid prop
selected
supplied toTypeaheadContainer(WrappedTypeahead)
.
Can somebody help me in finding the right way of doing this??? Many thanks and bye ....