New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Firebase Firestore: Can't find variable: crypto #7507
Comments
@RazaShehryar Did you use? import firebase from 'firebase';
import 'firebase/firestore'; |
Yes I did exactly. Still facing the issue |
@RazaShehryar Could you send a more detailed code here? It would be nice as a gist, please. Why are you using with |
import firebase from 'firebase';
import 'firebase/firestore'; I think you don't need the |
I tried and not it says _Firebase.default.firestore is not a function. (In '_Firebase.default.firestore()', '_Firebase.default.firestore' is undefined) |
@RazaShehryar - post a mcve (https://stackoverflow.com/help/mcve) |
Oh well. I did some research and found out that there's some kind of bug with Firebase FB SDK with React Native. To resolve the issue, I had to include the following in my App.js.
Note: You'll need to install base-64 first (npm install base-64). |
I am having this same exact issue.
|
I resolved this issue @RazaShehryar using your code. In my config file I run:
I understand how it works, this is used to generate the document id correct? Can you explain why I need to do this, however? |
I'm not really sure that Here is an issue with a similar problem: #7209. |
do you have any idea why we have to do all this. |
I am not sure. For some reason, Firebase SDK isn't supported well for React Native. I am using Expo to build the app so I guess there won't be an issue if you are using react-native-firebase. As @ishaansehgal99 stated, it is used to generate doc id. |
using react-native-firebase module solve the problem |
To solve the problem, please go through this solution. It worked for me and now I am not getting any warnings. |
https://gist.github.com/RazaShehryar/350b439627a99796658d552fcd180b02 |
I put this in my App.js file with no luck. Can you help me? |
This worked for me π― To sort this out you need to hard code the value, increase the value of the variable MAX_TIMER_DURATION_MS. Here are the steps: Go to node_modules/react-native/Libraries/Core/Timer/JSTimers.js Look for the variable MAX_TIMER_DURATION_MS Change 60 * 1000 to 10000 * 1000 Save the changes and re-build your app. From SohamToraskar |
Thanks, but I was referring to the "can't find variable crypto" problem haha |
Are you sure you are putting the mentioned gist in the top root of App.js? |
I think so, I only have one App.js file which is at the root of my project |
If you can show me your code, I might be able to help you out.
If you can show me your code, I might be able to help you out. |
Here's my App.js file: https://gist.github.com/andmar204/3a8b90afd2f46d4ec66539c8feed2b72 |
Have you installed base-64? (npm install base-64) |
I believe so, but I'll run the install command just in case |
Ok, so I ran npm install base-64 and ran my project, and I still get the error. I'm not sure if this will help, but here's my error screen. |
I have exactly the same problem. Downgrading to firebase@7.9.0 fixes the issue for me. Every release after that leads to either βatobβ or βcryptoβ missing |
i'd sugget opening an issue on firebase-js-sdk about this: https://github.com/firebase/firebase-js-sdk |
This worked! Thank you so much, I would've never thought of that. |
In debug mode i haven't problem, but with debug mode disabled the error appears. |
maybe we should make |
Just out of context question, when you guys are adding Phone Auth in expo? I can see that SDK 37 has been released but the documentation says it is still in testing mode? |
@RazaShehryar - @IjzerenHein is working on it! it's coming soon |
@RazaShehryar // Add a new document with a generated id. // later... https://firebase.google.com/docs/firestore/manage-data/add-data?hl=pt-br |
locking this thread temporarily, if you come here with this issue keep in mind the solution presented above:
|
Hey guys, we're working on getting this problem resolved! I've done some investigating and found that there have been regressions in the Firebase JS SDK recently which make Firestore break in the react-native environment. Here are the versions that have been tested:
Also, the problem does not happen when Because of this, please use |
π Hi there! Did you run into this error? Here's a quick shortcut to the workaround provided by @jan-kn
Downgrading to firebase@7.9.0 fixes the issue for me. Every release after that leads to either βatobβ or βcryptoβ missing
Original post:
Expo Diagnostics:
Expo CLI 3.16.1 environment info:
System:
OS: macOS 10.15.2
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.14.1 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6241897
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
npmPackages:
expo: ^36.0.2 => 36.0.2
react: ~16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4
npmGlobalPackages:
expo-cli: 3.16.1
I am using Firebase Firestore services. I am getting the following error:
Can't find variable: crypto
Here's my code:
const firebaseConfig = {
apiKey: "XXX",
authDomain: "XXX",
databaseURL: "XXX",
projectId: "XXX",
storageBucket: "XXX"
};
firebase.initializeApp(firebaseConfig);
const dbh = firebase.firestore();
try {
await dbh
.collection("Requests")
.doc("mario")
.set({
employment: "plumber",
outfitColor: "red",
specialAttack: "fireball"
});
} catch (error) {
console.log(error);
}
The text was updated successfully, but these errors were encountered: