在使用包含 "allowOtherValues" 的自动完成项的对象数组时,inputValue.trim 不是一个函数
我有一个自动完成实现,其中我使用了一个对象数组来表示项目,我也希望将 allowOtherValues 属性设置为 true,但当我尝试从选项中选择任何项目时,我会收到“inputValue.trim 不是一个函数”的错误。以下是我的代码(抱歉,格式不正确,我不知道为什么会出现这种情况):
export const Simple = ({ name }: SimpleProps) => { return ( <> <Autocomplete items={[ { name: 'TABLE 1', tableId: 'table1' }, { name: 'TABLE 2', tableId: 'table 2' }, ]} itemToString={(item) => (item ? item.name : '')} onChange={(item) => console.log(item)} allowOtherValues={true} initialInputValue="TABLE 1" > {(props) => { const { getInputProps, getRef, inputValue, openMenu } = props; return ( <TextInput placeholder="Open on focus" value={inputValue} ref={getRef} {...getInputProps({ onFocus: () => { openMenu(); }, })} /> ); }} </Autocomplete> </> ); };
内容来源: segmentio/evergreen