首页 > 解决方案 > 没有结果 react-native-searchable-dropdown

问题描述

我使用 react-native-searchable-dropdown 库,但是如果用户在项目数组中写入字符串,我会收到白屏。如何不添加任何结果文本(或创建缺失选项的最佳选项按钮)?

标签: react-nativesearchable-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}
 />
 

如果没有找到搜索结果,这将显示。


推荐阅读