I created a function to iterate through all fields of a DataSnapshot
.
Here are my imports
import type {
DataSnapshot,
DocumentRef,
DocumentSnapshot,
} from 'react-native-firebase';
the function is below:
getRefData = (data: typeof DataSnapshot) {
return new Promise(async (resolve: Function) =>{
const refs = await Object.keys(data).map((key: string) => {
const field = data[key];
if (field instanceof DocumentRef) {
/// LOGIC HERE
}
});
});
};
I'd actually like to add some logic if field is a DocumentRef
. It is even undefined, see error below:
Unhandled rejection is {promise: Promise, reason: ReferenceError: DocumentRef is not defined
at blob:http://localhost:8081/68a9c3b0-2327-429a-b5c7…}
Is there a different or straightforward way to do this? What could've gone wrong?