kumar barian
kumar barian

Reputation: 139

Not able to set the data to firestore

I am trying to append some data to my collection('user) with my doc('userName') .set with few datas (phone number, age) (array format).

Here is the code :

import firestore from '@react-native-firebase/firestore';

  firestore()
  .collection('user')
  .doc('userName')
  .set({
    number: '034093434',
    age: 30,
  })
  .then(() => {
    alert('added to firestore');
  });

But i am getting error says that :

TypeError: this._firestore.native.documentSet is not a. function. (In this._firestore.native.documentSet(this.path,(0,_serialize.buildNativeMap(data), setOptions);' this._firestore.native.documentSet' is undefined)

Not sure what i am missing.I followed this doc -> here.

Each time i will set the new data. so it should add as array (index wise).

Any help would be great. Thanks

Upvotes: 1

Views: 1900

Answers (4)

Jaydeep Kataria
Jaydeep Kataria

Reputation: 867

if this is happen in iOS device then kindly do pod install

The native RNFirestore module is missing so that this error is coming

After yarn @react-native-firebase/firestore you need to run pod install and trigger a rebuild with react-native run-ios.

Upvotes: 1

kemalony
kemalony

Reputation: 195

faced same issue in IOS after

npm i @react-native-firebase/firestore

I run cd ios & pod install then react-native run-ios --simulator="iPhone 8" it worked fine

Upvotes: 0

Happy-Monad
Happy-Monad

Reputation: 2002

This same error was reported on Github's page and was caused by an incomplete installation of the library. To check for that I wuld suggest to try running:

firestore().collection('user').add({a: 'a'})

If it returns the same error most likely it's the same issue and could be solved unistalling/reinstalling the library and then running react-native run-android as pointed out in the Github and this comment on another thread.

If that doesn't solve the problem I would suggest to report it on Github.

Upvotes: 0

You should add

import import firebase from '@react-native-firebase/app';

before

import firestore from '@react-native-firebase/firestore';

like this

import import firebase from '@react-native-firebase/app';
import firestore from '@react-native-firebase/firestore';

  firestore()
  .collection('user')
  .doc('userName')
  .set({
    number: '034093434',
    age: 30,
  })
  .then(() => {
    alert('added to firestore');
  });

Upvotes: 0

Related Questions