3

I'm sorry I tried googling it, tried reading the documents which came up with and other stackoverflow posts which mentioned using 'DocumentSnapshot' or firestore.documentdata. but it didn't work.

I tried object too. Only any works unfortunately.

Here are my imports

import logo from './logo.svg';
import './App.css';

import 'firebase/firestore';
import { useFirestoreDocData, useFirestore } from 'reactfire';
import { FireObject } from '@testing-library/dom';

And Here's the Code

function Burrito() 
  const burritoRef = useFirestore()
    .collection('tryreactfire')
    .doc('burrito');

  const { status, data }: { status: any; data: any }  =         
  useFirestoreDocData(burritoRef);

  if (status === 'loading') {
    return <p>Fetching burrito flavor...</p>;
  }

  return <p>The burrito is {data.yummy ? 'good' : 'bad'}!</p>;
}
CarinaCase
  • 243
  • 2
  • 7
  • 1
    Burrito is something you built ? If it is you should create a type for it, I don't think firebase is smart enough to give you a type for your data. – Nicolas Menettrier Jun 09 '21 at 06:31
  • Here you can see what it returns https://github.com/FirebaseExtended/reactfire/blob/81888023e84ec015ed9a91eb744aabec3d2fbecc/src/firestore.tsx#L78 – ruohola Jun 09 '21 at 06:31
  • Well all I did was follow this tutorial here: https://github.com/FirebaseExtended/reactfire/blob/main/docs/quickstart.md so burrito is a document in Firebase collection, and it has a field of yummy which is either set to true or false – CarinaCase Jun 09 '21 at 06:35
  • @ruohola Should I make type this then --> firebase.firestore.DocumentReference ? I'm a bit confused – CarinaCase Jun 09 '21 at 06:39
  • Hey @CarinaCase, could you move the question from title to the body of this thread and elaborate a bit on what you are trying to achieve? Thanks – Farid Shumbar Jun 09 '21 at 13:36

0 Answers0