Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
React Native with Firebase v9

i am new to react native ,i am trying to fetch the data from my firebase database. i am trying to list out name and age from my firestore collection,

here is my code:

const HomeNurse=({ navigation }) => {

    const [users, setUsers] = useState([]);
    const [currentPage, setCurrentPage] = useState(1);
    const [isLoading, setIsLoading] = useState(false);
  
    const getUsers = async () => {
      let result = [];
      
      const querySnapshot = await getDocs(collection(db, "MyCollection"));
      querySnapshot.forEach((doc) => {
        console.log(doc.id, "=>" , doc.data());
        result.push(doc.data());
      });
  
      setUsers([...result]);
    };
  
    useEffect(() => {
      getUsers();
    }, []);
  
    const renderItem = ({ item }) => {
      return (
        <View>
          <View>
            <Text>{`${item.name}`}</Text>
            <Text>{`${item.age}`}</Text>
          </View>
        </View>
      );
    };
  
    const renderLoader = () => {
      return isLoading ? (
        <View style={styles.loaderStyle}>
          <ActivityIndicator size="large" color="#aaa" />
        </View>
      ) : null;
    };
  
    const loadMoreItem = () => {
      setCurrentPage(currentPage + 1);
    };
  
    return (
      <View>
        <StatusBar backgroundColor="#000" />
        <FlatList
          data={users}
          renderItem={renderItem}
          keyExtractor={(item) => item.id}
          ListFooterComponent={renderLoader}
          onEndReached={loadMoreItem}
          onEndReachedThreshold={0} />
      </View>
    );
  };
  
 

the output is just a blank screen with a warning:

Possible Unhandled promise rejection id:0

at the terminal:

[Unhandled promise rejection: TypeError: (0, _firebase.collection) is not a function. (In '(0, _firebase.collection)(_firebase.db, "MyCollection")', '(0, _firebase.collection)' is undefined)]

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!