はじめに
ReactNativeとFirebaseを組み合わせていた際に以下のようなエラーが出た
Unhandled promise rejection: ReferenceError: Can't find variable: atob
Firebase7.9.1以降のバージョンで多くの人が遭遇しているらしい
Firebaseのバージョンを7.9.0に戻すことでも解決できるとは思うが、以下の方法でも解決できた。
base-64モジュールをインストール
$ npm install base-64
問題のページの一番先頭に以下のコードを記入
index.js
if (!global.btoa) {
global.btoa = encode;
}
if (!global.atob) {
global.atob = decode;
}
import {decode, encode} from 'base-64';