Can#39;t find a variable 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.js中base64的全局导入解决了这个问题.
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
基础教程推荐
- 动态更新多个选择框 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 响应更改 div 大小保持纵横比 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 在for循环中使用setTimeout 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01