react-json-schema-form-extras icon indicating copy to clipboard operation
react-json-schema-form-extras copied to clipboard

typeahead: how to set initial value

Open mgrivera opened this issue 5 years ago • 0 comments

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 to TypeaheadContainer(WrappedTypeahead).

Can somebody help me in finding the right way of doing this??? Many thanks and bye ....

mgrivera avatar Aug 19 '19 12:08 mgrivera