- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在努力迁移 firebase v8 -> v9。我有一个带有 Storybook 的组件库,用于演示组件。该库通过 NPM/Github 包作为包发布。
迁移没有给我带来任何麻烦,除了这个。在我的网络应用程序中导入和使用以下组件时出现问题。
下面的代码在 Storybook 中完美运行,但在将组件导入我的网络应用程序时失败。
const useGetLanguages = (firestoreInstance: Firestore): Response => {
const [loading, setLoading] = useState(false)
const [data, setData] = useState<ILanguage[]>([])
console.log('firestoreInstance: ', firestoreInstance) // Logs firestore instance
const fetch = useCallback(() => {
if (!firestoreInstance) return
setLoading(true)
const collectionRef = collection(firestoreInstance, 'data')
console.log('blip') // this logs fine
getDoc(doc(collectionRef, 'tags')) // crashes here...
.then(res => {
const data = res?.data()?.languages
if (data) {
const languages = (Object.values(data) as unknown) as ILanguage[]
if (languages) {
setData(languages.sort(sortBy('name')))
}
}
})
.finally(() => {
setLoading(false)
})
}, [firestoreInstance])
我最初使用:
getDoc(doc(firestoreInstance, 'data', 'tags'))
这在 Storybook 中也有效,但是在我的网络应用程序中使用此 Hook 导航到页面时,出现此错误:
Uncaught FirebaseError: Expected first argument to collection() to be a CollectionReference,a DocumentReference or FirebaseFirestore
我看过类似的问题,但没有解决问题。任何输入将不胜感激!
编辑:我正在像这样导入 firebase:
// firebaseConfig.ts
import { FirebaseOptions, initializeApp } from 'firebase/app'
import { getAuth } from 'firebase/auth'
import { getFirestore } from 'firebase/firestore'
import { getFunctions } from 'firebase/functions'
const config: FirebaseOptions = {
// ...config
}
export const app = initializeApp(firebaseConfig)
export const authInstance = getAuth(app)
export const firestoreInstance = getFirestore(app)
export const functionsInstance = getFunctions(app)
然后我导入 firestoreInstance
并将其传递给从包中导入的函数/组件。
我将尝试传递配置本身并在包中使用它并发布结果。
最佳答案
原来是我们这边失误了。我们需要在 package.json
中将 firebase 作为 peerDependency
安装。迁移到 MUI 5 时遇到了类似的问题。如果其他人遇到在您的情况下没有意义的模糊错误,可能值得一试,检查您的依赖项在哪里!
关于javascript - FirebaseError : Expected first argument to collection() to be a CollectionReference, a DocumentReference 或 FirebaseFirestore,正在迁移到 v9 firebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70112941/
我在 Firebase 中遇到了此错误,提示请求太多。我读过 Nest api 说他们限制了请求数量以避免设备上的电池耗尽。但在官方 Nest Android 应用程序上,您可以毫无问题地打开/关闭(
我正在编写一个更新到 Firebase 的应用程序,但我无法编写 oncancelled 函数,因为它无法解析符号 FirebaseError。 我的代码如下: package com.test.my
我收到以下错误。我的问题是 不是 有实际错误,但事实上它是说错误是 未捕获 .如果你看看我的auth.service.ts和 sign-in.component.ts文件我发现了错误。 我的问题是,为
我有需要抛出错误的情况。错误必须匹配 FirebaseError界面。 我试图导入这个接口(interface) import { FirebaseError } from '@firebase/ut
我正在使用 Firebase 用户身份验证、电子邮件/密码方法。我想测试我是否可以更改我的电子邮件,当电子邮件正确时,我总是收到无效的电子邮件,当我继续按更改(这是启动更改电子邮件方法的按钮)时,我得
好吧,事情就是这样,我已经在 Stackoverflow 中问了几个与 Firebase 相关的问题,即使没有任何答案,我也设法让 Firebase 正常工作,并收到了一堆通知。我真的不知道我做了什么
我对编码还是很陌生,所以请耐心等待!我已经按照 youtube 类(class)构建了一个笔记应用程序并获得了一个可以使用的基础,但是我现在在删除 firebase 中的笔记时随机出现这个错误,希望有
我正在尝试使用 onSnapshot 监听器获取从 firebase 显示的帖子数据,但显示此 Firebase 错误。有人可以帮助解决这个错误 App.js: import { useState,
什么时候做firebase推送通知 firebaseAdmin.messaging().sendMulticast(message) 我得到了错误 // Error: Requested entit
我正在尝试从云 Firestore 更新预先存在的信息。这是我的规则: rules_version = '2'; service cloud.firestore { match /database
运行以下查询时出现上述错误。我以前没有见过它,找不到任何关于它的文档,而且我没有做任何不寻常的事情或我以前没有做过的事情。任何人都可以阐明它吗? const getUserProjects = asy
我是 firebase 的新手,我在控制台中有一个错误,我真的不知道它的来源: redux-firestore listener error: FirebaseError: Missing or in
我是 firebase 的新手,我在控制台中有一个错误,我真的不知道它的来源: redux-firestore listener error: FirebaseError: Missing or in
我有一个查询,我在 desc 订单中使用如下查询 const { id } = userDetails; const initialQuery = await firestore().coll
我正在使用 Firebase service worker 进行网络推送通知。目前,我正面临这个错误: Uncaught FirebaseError: Messaging: This method i
function Chat() { const [input, setInput] = useState("") const [seed, setSeed] = useState(""
我正在尝试访问我的 firestore 集合中的所有文档 const app = initializeApp(firebaseConfig); const db = getFirestore(
我正在尝试创建一个文档引用,设置一个 onsnapshot 监听器,保存文档,然后上传一个文件,这将触发一个云功能,该功能将更新我正在收听的文档。但是 onSnapshot 在快照运行一次后(我猜是初
我更新了 Firebase for Web 应用程序的 Firebase SDK。 由于更新我的应用程序不再启动并引发以下错误: 知道发生了什么吗? Uncaught (in promise) Fir
以下代码可用于在 Firebase 中创建新用户,但在浏览器中出现以下错误,您能帮我理解为什么吗? Function DocumentReference.set() called with inval
我是一名优秀的程序员,十分优秀!