Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

Unable to load data from Firebase collection using React Native/Typescript

$
0
0

I'm a designer with little experience with Firebase, so forgive me if I'm not asking the right question. I recently migrated my React Native app from one Firebase account to another, and now data has stopped being pulled in to the app (but data is being received in Firebase).

The app essentially tracks a users habit (inputted from a user), and on the profile displays info from aggregated data that's a Collection from Firebase.

However, a function that should load the aggregated data within a view gives me an error saying that the data can't be found.

Here's the function that should be pulling the data from Firebase (as far as I can tell).

  // States  const [timeWindowType, setTimeWindowType] = React.useState<TimeWindowTypes>(    defaultWindowType,  );  const [overview, setOverview] = React.useState<OverviewStatisticsModel>(    OverviewStatisticsFactory.empty(defaultWindowType),  );  const [fetched, setFetched] = React.useState<Boolean>(false);  // Compount / Update  React.useEffect(() => {    if (fetched) return;    loadStats();  });  // Fetch  const loadStats = (type: TimeWindowTypes = TimeWindowTypes.weekly) => {    profileService      .getProfileSnapshot()      .then(({snap, ref}) => {        functions()          .httpsCallable('overviewStats')({            profileId: ref.id,          })          .then(async response => {            const {data} = response;            setOverview(data);            setFetched(true);          })          .catch(err => {            Alert.alert('No data has been found', err.message);          });      })      .catch(error => {});  };

I've noticed the .httpsCallable('overviewStats') in the function, but can't see the reference in Firebase. Could that be the cause?

I can share the other models "TimeWindowTypes" and "OverviewStatisticsModel" if it gives better insight into the problem.

Here's some images of the firebase firestore data.

Thanks in advance!

firebase

firebase


Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>