React_autosuggestion did not show suggestions while typing on input box even though the same code is copy pasted from documentation react-autosuggestion upi.
(即使从文档react-autosuggestion upi复制了相同的代码,React_autosuggestion在输入框上键入时也没有显示建议。)
<ReactAutocomplete
items={[
{ id: 'foo', label: 'foo' },
{ id: 'bar', label: 'bar' },
{ id: 'baz', label: 'baz' },
]}
shouldItemRender={(item, value) => item.label.toLowerCase().indexOf(value.toLowerCase()) > -1}
getItemValue={item => item.label}
renderItem={(item, highlighted) =>
<div
key={item.id}
style={{ backgroundColor: highlighted ? '#eee' : 'transparent'}} >
{item.label}
</div>
}
value={value}
onChange={e => setCurrentValue( e.target.value )}
onSelect={value => setCurrentValue( value )}
/>
imported as:
(汇入为:)
import ReactAutocomplete from 'react-autocomplete';
and the value is declared and set using a function:
(并使用函数声明和设置该值:)
const [value,setValue]=useState('');
const setCurrentValue=(value)=>{
console.log('hhhh',value)
setValue(value);
}
However, as shown in the screenshot below, the suggestion is not displayed.
(但是,如下面的屏幕快照所示,该建议未显示。)
ask by Goutham D translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…