<i id='ah9OO'><tr id='ah9OO'><dt id='ah9OO'><q id='ah9OO'><span id='ah9OO'><b id='ah9OO'><form id='ah9OO'><ins id='ah9OO'></ins><ul id='ah9OO'></ul><sub id='ah9OO'></sub></form><legend id='ah9OO'></legend><bdo id='ah9OO'><pre id='ah9OO'><center id='ah9OO'></center></pre></bdo></b><th id='ah9OO'></th></span></q></dt></tr></i><div id='ah9OO'><tfoot id='ah9OO'></tfoot><dl id='ah9OO'><fieldset id='ah9OO'></fieldset></dl></div>

      <tfoot id='ah9OO'></tfoot>
      <legend id='ah9OO'><style id='ah9OO'><dir id='ah9OO'><q id='ah9OO'></q></dir></style></legend>

      <small id='ah9OO'></small><noframes id='ah9OO'>

        <bdo id='ah9OO'></bdo><ul id='ah9OO'></ul>
      1. 如何在继续之前等待获取 Firebase 数据?

        时间:2023-10-02
      2. <small id='ITMTX'></small><noframes id='ITMTX'>

          <legend id='ITMTX'><style id='ITMTX'><dir id='ITMTX'><q id='ITMTX'></q></dir></style></legend>
              <tbody id='ITMTX'></tbody>
              <bdo id='ITMTX'></bdo><ul id='ITMTX'></ul>

            • <tfoot id='ITMTX'></tfoot>
              1. <i id='ITMTX'><tr id='ITMTX'><dt id='ITMTX'><q id='ITMTX'><span id='ITMTX'><b id='ITMTX'><form id='ITMTX'><ins id='ITMTX'></ins><ul id='ITMTX'></ul><sub id='ITMTX'></sub></form><legend id='ITMTX'></legend><bdo id='ITMTX'><pre id='ITMTX'><center id='ITMTX'></center></pre></bdo></b><th id='ITMTX'></th></span></q></dt></tr></i><div id='ITMTX'><tfoot id='ITMTX'></tfoot><dl id='ITMTX'><fieldset id='ITMTX'></fieldset></dl></div>

                1. 本文介绍了如何在继续之前等待获取 Firebase 数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 .onSnapshot 从 Fire 存储中实时获取数据,效果很好,我正在按预期接收数据.问题是我正在接收多组数据,组件并没有等到接收到所有数据才渲染.

                  I am fetching data from Fire store in real-time with .onSnapshot and it works great, I am receiving the data as expected. The problem is that I am receiving multiple sets of data, and the component does not wait until all the data is received before rendering.

                  所以我的问题是,对于我当前的代码,它们是否可以让我在显示它们之前等待获取所有数据集?

                  So my question is, with my current code, is their a way in which I can wait for all sets of my data to be fetched before displaying them?

                  我当前的代码是:

                  import React, {useEffect, useState} from 'react';
                  import {ActivityIndicator, Dimensions, Text, View} from 'react-native';
                  import firestore from '@react-native-firebase/firestore';
                  import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
                  import FolloweringScreens from './FolloweringScreens';
                  import {TouchableOpacity} from 'react-native-gesture-handler';
                  
                  const {width, height} = Dimensions.get('screen');
                  
                  function Following({urlname, navigation}) {
                    const [followingData, setfollowingData] = useState([]);
                  
                    // Follower counts, displayname, image
                    const fetchData = () => {
                      const dataRef = firestore().collection('usernames');
                  
                      dataRef
                        .doc(urlname)
                        .collection('Following')
                        .onSnapshot((snapshot) => {
                          snapshot.forEach((doc) => {
                            dataRef.doc(doc.id.toLowerCase()).onSnapshot((followerDoc) => {
                              const data = followerDoc.data();
                              setfollowingData((prev) => [
                                ...prev,
                                {
                                  profileName: doc.id,
                                  displayName: data.userName,
                                  followerCount:
                                    data.followers !== undefined ? data.followers : 0,
                                  followingCount:
                                    data.following !== undefined ? data.following : 0,
                                  image: data.imageUrl ? data.imageUrl : null,
                                },
                              ]);
                            });
                          });
                        });
                    };
                  
                    useEffect(() => {
                      fetchData();
                    }, []);
                  
                    return (
                      <>
                        <View
                          style={{
                            left: width * 0.04,
                            top: 50,
                            flexDirection: 'row',
                            alignItems: 'center',
                            width: '80%',
                            height: '4%',
                            marginBottom: 5,
                          }}>
                          {/* {console.log('followin', followingData)} *
                2. <i id='Vmcac'><tr id='Vmcac'><dt id='Vmcac'><q id='Vmcac'><span id='Vmcac'><b id='Vmcac'><form id='Vmcac'><ins id='Vmcac'></ins><ul id='Vmcac'></ul><sub id='Vmcac'></sub></form><legend id='Vmcac'></legend><bdo id='Vmcac'><pre id='Vmcac'><center id='Vmcac'></center></pre></bdo></b><th id='Vmcac'></th></span></q></dt></tr></i><div id='Vmcac'><tfoot id='Vmcac'></tfoot><dl id='Vmcac'><fieldset id='Vmcac'></fieldset></dl></div>

                      <tbody id='Vmcac'></tbody>

                      <bdo id='Vmcac'></bdo><ul id='Vmcac'></ul>
                      <tfoot id='Vmcac'></tfoot>

                        <small id='Vmcac'></small><noframes id='Vmcac'>

                        1. <legend id='Vmcac'><style id='Vmcac'><dir id='Vmcac'><q id='Vmcac'></q></dir></style></legend>