0
I’m trying to get the information from my collection in firebase but am getting the following error:
Typeerror: Undefined is not an Object (evaluating '_firebaseConnection.default.db.Collection')
this is my firebase code
import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';
import 'firebase/database';
let firebaseConfig = {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: ""
};
if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig)
}
const db = firebase.firestore();
export {db}
export default firebase;
the firestore only appears when I put:
const db = firebase.firestore();
export default {
firebase,
db
};
from this above format I cannot exit the auth error application
Code from my book screen where the error occurs:
import React, { useEffect, useState } from "react";
import {
StatusBar,
FlatList, View
} from "react-native";
import * as OpenAnything from "react-native-openanything";
import {
Container,
InpuText,
ViewFlatlist,
Image,
TextOne,
ButtomSimple,
TextButtom,
ContainerRow,
ContainerInput,
} from "./styles";
import { Card } from "react-native-elements";
import firebase from '../../services/firebaseConnection';
export default function Libery() {
const [Libery, setLibery] = useState([]);
useEffect(() => {
firebase.db.collection("biblioteca").onSnapshot((querySnapshot) => {
const Libery = [];
querySnapshot.docs.forEach((doc) => {
const { title, category, uri, pdf } = doc.data();
Libery.push({
id: doc.id,
title,
category,
uri,
pdf
});
});
console.log(Libery)
setLibery(Libery);
});
}, []);
How’s the import in the component?
– Rafael Tavares
import React, { useEffect, useState } from "react"; import { StatusBar, FlatList, View } from "react-native"; import * as OpenAnything from "react-native-openanything"; import { Container, InpuText, ViewFlatlist, Image, TextOne, ButtomSimple, TextButtom, ContainerRow, ContainerInput, } from "./styles"; import { Card } from "react-native-elements"; import firebase from '../../services/firebaseConnection'; export default function Libery() { const [Libery, setLibery] = useState([]);
– Lorita 0800