Last update to useEffect methods
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { Searchbar } from 'react-native-paper';
|
||||
import { View, ActivityIndicator, StyleSheet, SafeAreaView, FlatList } from 'react-native';
|
||||
import { StyleSheet, SafeAreaView, FlatList } from 'react-native';
|
||||
import API from "../API";
|
||||
import UserName from "../components/UserName";
|
||||
import GroupCard from "../components/GroupCard";
|
||||
import ProfileSmallHeader from '../components/ProfileSmallHeader.js'
|
||||
|
||||
const Groups = () => {
|
||||
const [searchQuery, setSearchQuery] = React.useState('');
|
||||
@@ -12,9 +10,14 @@ const Groups = () => {
|
||||
const [queryTimer, setQueryTimer] = React.useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
let subscribed = true;
|
||||
API.getRecentGroups('').then((data) => {
|
||||
setGroups(data.groups || []);
|
||||
if (subscribed)
|
||||
setGroups(data.groups || []);
|
||||
});
|
||||
return () => {
|
||||
subscribed = false;
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
||||
@@ -39,7 +42,7 @@ const Groups = () => {
|
||||
return (<GroupCard profileObj={item} />);
|
||||
});
|
||||
return (
|
||||
<SafeAreaView style={{flex: 1}}>
|
||||
<SafeAreaView style={{ flex: 1 }}>
|
||||
<Searchbar
|
||||
placeholder="Search Groups"
|
||||
onChangeText={onChangeSearch}
|
||||
@@ -48,7 +51,7 @@ const Groups = () => {
|
||||
<FlatList
|
||||
contentContainerStyle={styles.container}
|
||||
numColumns={2}
|
||||
columnWrapperStyle={{justifyContent: "space-evenly"}}
|
||||
columnWrapperStyle={{ justifyContent: "space-evenly" }}
|
||||
data={groups}
|
||||
renderItem={renderProfile}
|
||||
keyExtractor={item => item._id}
|
||||
|
||||
Reference in New Issue
Block a user