如何解决AsyncTypeAhead在React JS中不起作用-输入2个字符后输入字段正在重置
嗨,我正在尝试在React中实现异步Typeahead。 现在一切正常,除了我输入2个键时,该字段正在重置。有人可以告诉我我要去哪里错了吗?
<AsyncTypeahead
id="basic-typeahead-example"
labelKey={(optionsUsers) => `${optionsUsers.name}`}
allowNew={false}
multiple={false}
className="col-md-8"
onSearch={(e) => {
GET('all-users?',`query=${e}`).then((res) => {
switch (res.status) {
case 200:
case 201:
let options = [];
res.data.data.map((record,index) => {
options.push({
id: index,name:
record.firstName + ' ' + record.lastName,value: record.slug,});
});
setOptionsUsers(options);
break;
default:
alert('Error');
}
});
}}
// onChange={(e) => {
// setUser(e);
// }}
// ref={ref}
// onBlur={(e) => {
// if (!user) ref.current.clear();
// }}
options={optionsUsers}
selected={user}
/>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。