Last update to useEffect methods
This commit is contained in:
@@ -12,9 +12,14 @@ const Search = () => {
|
||||
const [queryTimer, setQueryTimer] = React.useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
let subscribed = true;
|
||||
API.searchProfiles('').then((data) => {
|
||||
setProfiles(data.profiles || []);
|
||||
if (subscribed)
|
||||
setProfiles(data.profiles || []);
|
||||
});
|
||||
return () => {
|
||||
subscribed = false;
|
||||
}
|
||||
}, [])
|
||||
|
||||
const onChangeSearch = query => {
|
||||
@@ -31,7 +36,7 @@ const Search = () => {
|
||||
return (<ProfileCard profileObj={item} />);
|
||||
});
|
||||
return (
|
||||
<SafeAreaView style={{flex:1}}>
|
||||
<SafeAreaView style={{ flex: 1 }}>
|
||||
<Searchbar
|
||||
placeholder="Search Users"
|
||||
onChangeText={onChangeSearch}
|
||||
@@ -41,7 +46,7 @@ const Search = () => {
|
||||
<FlatList
|
||||
contentContainerStyle={styles.container}
|
||||
numColumns={2}
|
||||
columnWrapperStyle={{justifyContent: "space-evenly"}}
|
||||
columnWrapperStyle={{ justifyContent: "space-evenly" }}
|
||||
data={profiles}
|
||||
renderItem={renderProfile}
|
||||
keyExtractor={item => item._id}
|
||||
|
||||
Reference in New Issue
Block a user