【发布时间】:2017-06-29 11:46:50
【问题描述】:
我需要为我的应用创建搜索栏。我目前正在使用react-native-material-ui,this,但我有问题。
1- 它会导致真实设备上的延迟。
2- 我如何在“搜索栏”中搜索项目。我的渲染方法上有这段代码:
<View style={{marginBottom: 50}}>
<ThemeProvider uiTheme={uiTheme}>
<Toolbar uiTheme={uiTheme}
leftElement="arrow-back"
onLeftElementPress={() => goBack()}
centerElement={params.tapName}
searchable={{
autoFocus: true,
placeholder: 'Search',
onChangeText: (text) => {
this.setState({currentSearch: text});
for (var i = 0; i < this.state.brands.length; i++) {
if(this.state.brands[i].name.search(text) != -1)
console.warn(this.state.brands[i].name);}},
}}
/>
</ThemeProvider>
</View>
我可以找到品牌的名称,但无法过滤和呈现它们。如果您知道如何呈现这些过滤的项目,或者知道更好的搜索栏,我正在等待您的答案。
【问题讨论】:
-
你应该不能访问
onChangeText中的状态变量 -
您可以将您的搜索代码添加到另一个函数中并调用
onChangeText。
标签: android reactjs react-native material-ui searchbar