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
update doc with arrayUnion gives error #1776
Comments
Any idea on this issue? |
@udarts what does |
Imported from react-native-firebase |
Oh, sorry missed a small thing, I am loading the react-native-firebase in a separate file and them loading that file in every component I use. The file looks like the following: import RNfirebase from 'react-native-firebase';
const instance = RNfirebase.app();
export default instance; |
Ok thanks, that'll be your problem then - the statics are only accessible from the module export and not the import rnfirebase from 'react-native-firebase';
// correct
rnfirebase.firestore.FieldValue.arrayUnion(userId);
// incorrect (what you're doing currently)
rnfirebase.app().firestore.FieldValue.arrayUnion(userId); Hope that helps, will close the issue now. Loving
|
Thanks for your reply. Although it might be a bit different, this is how it is setup on my end: I have a file called: firebase.js, inside is the code I posted above: import RNfirebase from 'react-native-firebase';
const instance = RNfirebase.app();
export default instance; Then on multiple components I call that firebase.js file like the following: import firebase from '../firebase'; Then in that way I am calling: firebase.firestore.FieldValue.arrayUnion(userId) Am I missing anything? |
@Salakar Any idea on this? |
@Salakar I've made a change and now use When I now try to update a doc with the following code:
In Firestore it is shown as:
While I thought it should be:
|
A similar case like this one #1776 (comment) for me too. Code
Screenshot from firebase database Console Log of updating object. |
Issue
I am trying to update a document in firestore, to add users uid to a userhasread array, but using the following code, gives an error:
It produces the following error:
Both: this.state.id and userId exist (did a console.log on both).
Project Files
iOS
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
Android
android/build.gradle
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:<!-- N/A -->
Environment
ADD_SOMETHING_HERE
e.g. iOS 10 or Android API 28N/A
N/A
N/A
Xcode 10
Android studio (latest version)
React Native
version: **0.57.8
React Native Firebase
library version: **5.1.1
Firebase
module(s) you're using that has the issue:TypeScript
?N/A
ExpoKit
?ExpoKit
N/A
Think
react-native-firebase
is great? Please consider supporting the project with any of the below:React Native Firebase
andInvertase
on TwitterThe text was updated successfully, but these errors were encountered: