Hi guys I add this error and I don't understand why... I'm using the starter project of react-native-firebase, and I'm trying to use firestore
Asked
Active
Viewed 416 times
0
2 Answers
1
Although there might be an issue with the library which needs investigating, your code is generally wrong. State in a React component should be data which when changed, causes a re-render. You do not need to assign your collection to state, this can be done as a class property. Also, using a constructor & componentWillMount is wrong as they're essentially the same thing - I don't know enough how it'd handle both cases internally though.
Your code would better work like so:
constructor() {
super();
this.ref = firebase.firestore().collection('users');
}
componentDidMount() {
this.ref.add({ name: 'moo' });
}

Alias
- 2,983
- 7
- 39
- 62
0
I have got same error. Please create the collection with the name 'users' and add a dummy document. Then try.

gypsicoder
- 5,416
- 5
- 24
- 38