react-native - 没有结果 react-native-searchable-dropdown
问题描述
我使用 react-native-searchable-dropdown 库,但是如果用户在项目数组中写入字符串,我会收到白屏。如何不添加任何结果文本(或创建缺失选项的最佳选项按钮)?
解决方案
如果您使用 flatlist 列出所有数据。有一个叫 ListEmptyComponent 的道具
import React from 'react',
import {FlatList, Button, Text} from 'react-native',
const emptyComponent = () => {
return(
<Text>Search result not found</Text>
<Button title='Do Something'/>
)
};
<FlatList
istEmptyComponent={emptyComponent}
/>
如果没有找到搜索结果,这将显示。
推荐阅读
- bash - 从 aws ec2 实例中检索准确的标签值
- javascript - 如何让反应电子忽略未定义的错误?
- python - Keras微调InceptionV3张量维度误差
- ruby-on-rails - Rails 部分黑客攻击:每个部分传递 2 条记录?还是更好的主意?
- r - 响应必须有 3 个或更多级别
- excel - 无法执行宏 - 找不到错误“76”路径
- python - 为什么 python 元组工厂函数比列表工厂函数慢?
- c++ - c++-使用BST实现策略表报错
- pandas - Pandas:如何获得每组中的前 2 行、中 2 行和后 2 行
- python-2.7 - 我正在使用 python 2.7。面临“END”关键字的问题