找不到变量 atob

Can#39;t find a variable atob(找不到变量 atob)

本文介绍了找不到变量 atob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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>
    )
}

控制台

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

Stack trace:
  node_modules@firebasefirestoredistindex.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 变量?

I just followed the guide in the expo documentation but still don't know why this problem is occurring. Need a clear explanation on this. And also what is atob variable?

推荐答案

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

I have tried downgrading but that's not resulted as a solution to me. I don't know why.

app.jsbase64的全局导入解决了这个问题.

The global import of base64 in the app.js resolved this problem.

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

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

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

感谢您的回复.

这篇关于找不到变量 atob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:找不到变量 atob

基础教程推荐