【发布时间】:2020-06-07 05:35:55
【问题描述】:
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\@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 变量?
【问题讨论】:
-
除非某些包碰巧命名了类似的名称,否则
atob是一个解码 Base64 编码字符串的函数。另一方面,btoa将字符串编码为 Base64 (Base64 encoding and decoding) -
感谢您的回复。为什么这个 atob 警告会显示在控制台中?你能找出代码中的问题吗?
-
可能是因为 atob 函数是浏览器环境中
window的一部分,除非特别移植,否则它不可用。你可以尝试下载一个 NPM 模块。 -
对于 React Native 使用
react-native-firebase. -
有人可以解释如何连接到 Firestore 以及为什么会发生 atob 吗?
标签: javascript firebase react-native expo