Javascript Can';我找不到一个变量

Javascript Can';我找不到一个变量,javascript,firebase,react-native,expo,Javascript,Firebase,React Native,Expo,Screen1.js import React,{useEffect} from 'react' import {View,Text} from 'react-native' import * as firebase from 'firebase/app'; import '@firebase/firestore'; const Screen1 = props =>{ useEffect(() => { var dbh = firebase.fi

Screen1.js

import React,{useEffect} from 'react'
import {View,Text} from 'react-native'
import * as firebase from 'firebase/app';
import '@firebase/firestore';

const Screen1 = props =>{

    useEffect(() => 
    {
        var dbh = firebase.firestore().collection("Jots").doc("note");
        dbh.set({name:"pradeep"}) //The yellow warning is popped up in this line.
    }); 

    return(
             <View>
                <Text>Title</Text>
             </View>
    )
}
import React,{useffect}来自“React”
从“react native”导入{View,Text}
从“firebase/app”导入*作为firebase;
导入“@firebase/firestore”;
常量屏幕1=道具=>{
useffect(()=>
{
var dbh=firebase.firestore().collection(“Jots”).doc(“note”);
set({name:“pradeep”})//在这一行中弹出黄色警告。
}); 
返回(
标题
)
}
控制台

[Unhandled promise rejection: ReferenceError: Can't find variable: atob]

Stack trace:
  node_modules\@firebase\firestore\dist\index.cjs.js:23101:0 in <global>
  http://192.168.0.108:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:131203:60 in fromBase64String


[未处理的承诺拒绝:引用错误:找不到变量:atob]
堆栈跟踪:
节点\模块\@firebase\firestore\dist\index.cjs.js:23101:0 in
http://192.168.0.108:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:131203:60 在fromBase64String中

我只是遵循了世博会文档中的指南,但仍然不知道为什么会出现这个问题。我需要一个清楚的解释。还有什么是atob变量?

我找到了一个解决方法,我仍然在他们这边有一个bug。 他们两天前刚刚发布了7.9.1版。 尝试使用7.9.0

纱线添加firebase@7.9.0


我正在为它创建一个问题,请关注。

为我工作!感谢papay0,7.9.1版本确实有问题

npm install firebase@7.9.0
expo r -c # restard expo without cache

您可以
rm-rf./node_modules/&npm i

我尝试过降级,但这并不是我的解决方案。我不知道为什么

app.js中全局导入base64解决了此问题

import {decode, encode} from 'base-64'

if (!global.btoa) {  global.btoa = encode }

if (!global.atob) { global.atob = decode }

感谢您的回复。

谢谢@Pradeep。这在firebase 7.14.1上对我起了作用:

import {decode, encode} from 'base-64'

if (!global.btoa) {  global.btoa = encode }

if (!global.atob) { global.atob = decode }
像这样使用import


除非某个包碰巧命名了其他类似的名称,
atob
是一个解码Base64编码字符串的函数<另一方面,code>btoa将字符串编码为Base64(),感谢您的响应。为什么控制台中会显示此atob警告?你能在代码中找出问题所在吗?这可能是因为atob函数是浏览器env中
窗口的一部分,除非特别移植,否则该函数不可用。您可以尝试下载一个NPM模块。供React本机使用。有人能解释如何连接到firestore以及为什么会发生atob吗?感谢您的回复,但降级到较低版本仍然没有帮助。它仍然说“找不到变量atob”。我应该用atob包装JSON吗?我升级了,但没有用firebase 7.9.3进行任何操作。此解决方案为我解决了问题。也与
7.11.0
获得了相同的解决方案,answer在这里用
7.14.0
解决了问题。非常感谢。这个解决方案对我来说很有效,但7.14.0也面临同样的问题!对于TypeScript,我必须添加
constglobalany:any=global
使其工作,然后使用
globalAny
字段而不是
global
import firebase from 'firebase';
import 'firebase/firestore'