When I type, nothing shows up in the search bar, but it knows that I'm typing (from the print statements in my updateSearch function).(键入时,搜索栏中没有任何内容,但是它知道我正在键入(通过updateSearch函数中的打印语句)。)
From my understanding of the react-native searchBar, there isn't even anything I need to do for text to be showing up there, so I really have no idea how I could have screwed this up.(从对react-native searchBar的理解来看,甚至不需要做任何事情就可以在此处显示文本,因此我真的不知道该如何解决这个问题。) This is a part of a larger project.. but I'm praying this issue doesn't have anything to do with the rest of it.(这是一个较大项目的一部分。.但是我祈祷这个问题与其余部分无关。)
import React, { Component } from "react";
import {
View,
Text,
FlatList,
ActivityIndicator,
SafeAreaView,
StyleSheet
} from "react-native";
import Header from "../components/Header";
import { SearchBar, List, ListItem } from 'react-native-elements';
export default class Search extends React.Component {
constructor(props) {
super(props);
this.state = {
query: "",
data: []
};
}
renderHeader = () => {
return (
<SearchBar
placeholder="Type Here..."
onChangeText={this.updateSearch}
value={this.state.query}
lightTheme={true}
/>
);
}
updateSearch = text => {
console.log("text", text);
const formattedSearch = text.toLowerCase();
this.setState({ query: formattedSearch });
console.log("text", this.state.query);
};
render() {
return (
<SafeAreaView style={styles.container}>
<Header text={"Search"} />
<FlatList
ListHeaderComponent={this.renderHeader}
/>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: Expo.Constants.statusBarHeight
}
});
ask by Patrick Bartlett translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…