找不到变量atob

Pra*_*eep 13 javascript firebase react-native expo

屏幕1.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>
    )
}
Run Code Online (Sandbox Code Playgroud)

安慰

[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


Run Code Online (Sandbox Code Playgroud)

我只是按照世博会文档中的指南进行操作,但仍然不知道为什么会出现此问题。需要对此作出明确的解释。还有什么是atob变量?

Pra*_*eep 38

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

全球进口的base64app.js解决了这个问题。

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

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

if (!global.atob) { global.atob = decode }
Run Code Online (Sandbox Code Playgroud)

感谢您的回复。

  • 也与“7.11.0”相同,答案解决了问题 (2认同)

小智 11

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

npm install firebase@7.9.0
expo r -c # restard expo without cache
Run Code Online (Sandbox Code Playgroud)

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


pap*_*ay0 7

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

纱线添加 firebase@7.9.0

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