I have tried to write data to firestore from React Native App but it does not store in firestore. after, two minutes its throws a Warring message like "@firebase/firestore: Firestore (8.2.1): Connection WebChannel transport errored:" I don't know what should I do next. sometimes it stores correctly after 5 minutes. Please anyone can help me out?
App.js
import React, {Component} from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
TouchableHighlight,
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import firebase from 'firebase';
import firestore from 'firestore';
const firebaseConfig = {
apiKey: "***********************",
authDomain: "test1-c9930.firebaseapp.com",
projectId: "test1-c9930",
storageBucket: "test1-c9930.appspot.com",
messagingSenderId: "589565665201",
appId: "1:589565665201:web:d371e3971f45323e6d2790",
measurementId: "G-Q8XY5NFZBY"
};
const firebaseApp = firebase.initializeApp(firebaseConfig);
const itemRef2 = firebaseApp.firestore().collection('/Users');
type Props = {};
export default class App extends Component <Props> {
AddUser1(){
console.log("Hello world");
itemRef2
.add({
name: 'Ada Lovelace',
age: 30,
})
.then(() => {
console.log('User added!');
});
}
render(){
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<View style={styles.btn}>
<TouchableHighlight style={[styles.buttonContainer, styles.loginButton]} onPress={() => this.AddUser1()}>
<Text style={styles.loginText}>ADD</Text>
</TouchableHighlight>
</View>
</ScrollView>
</SafeAreaView>
</>
);
}
}
const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
buttonContainer: {
height:45,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
marginBottom:20,
width:250,
borderRadius:30,
},
loginButton: {
backgroundColor: "#00b5ec",
},
btn:{
paddingTop: 80,
paddingLeft: 30,
}
});
Error
WARN [2021-01-07T10:26:30.319Z] @firebase/firestore: Firestore (8.2.1): Connection WebChannel transport errored: {"a": {"C":
null, "K": [Circular], "a": {"A": 0, "B": [U], "C": true, "F": 45000, "G": false, "I": true, "J": -1, "K": "fkei2znAemdEFPLNZb4Qyw", "Ka": 5000, "Ma": false, "Na": false, "Oa": false, "P": 0, "Pa": 2, "Qa": undefined, "R": [Object], "S": 0, "T": 9648, "Ta": 1, "U": true, "Ua": 10000, "V": 4, "X": false, "Y": [Object], "a": null, "b": [zd], "c": [bc], "f": [Z], "fa": false, "g": [Array], "ga": undefined, "h": null, "ha": "https://firestore.googleapis.com/google.firestore.v1.Firestore/Write/channel", "i": null, "ia": "", "j": null, "ja": 8, "l": null, "m": null,
"ma": 12, "na": [U], "o": 3, "oa": 600000, "pa": "OJAkHeErpL4AySc4V-WL0cDUNRYRR5EJ", "qa": -1, "ra": [Ed], "s": null, "u": 0, "v": "gsessionid"}, "b": {"database": "projects/test1-c9930/databases/(default)"}, "c": {"a": [Object], "b": 4, "src": [Circular]}, "f": {"a": [Circular]}, "i": undefined, "j": false, "l": true, "m": true, "o": "https://firestore.googleapis.com/google.firestore.v1.Firestore/Write/channel"}, "defaultPrevented": false, "status": 1, "target": {"C": null, "K": [Circular], "a": {"A": 0, "B": [U], "C": true, "F": 45000, "G": false, "I": true,
"J": -1, "K": "fkei2znAemdEFPLNZb4Qyw", "Ka": 5000, "Ma": false, "Na": false, "Oa": false, "P": 0, "Pa": 2, "Qa": undefined, "R": [Object], "S": 0, "T": 9648, "Ta": 1, "U": true, "Ua": 10000, "V": 4, "X": false, "Y": [Object], "a": null, "b":
[zd], "c": [bc], "f": [Z], "fa": false, "g": [Array], "ga": undefined, "h": null, "ha": "https://firestore.googleapis.com/google.firestore.v1.Firestore/Write/channel", "i": null, "ia": "", "j": null, "ja": 8, "l": null, "m": null, "ma": 12, "na": [U], "o": 3, "oa": 600000, "pa": "OJAkHeErpL4AySc4V-WL0cDUNRYRR5EJ", "qa": -1, "ra": [Ed], "s": null, "u": 0, "v": "gsessionid"}, "b": {"database": "projects/test1-c9930/databases/(default)"}, "c": {"a": [Object], "b": 4, "src": [Circular]}, "f": {"a": [Circular]}, "i": undefined, "j": false, "l": true, "m": true, "o": "https://firestore.googleapis.com/google.firestore.v1.Firestore/Write/channel"}, "type": "c"}
Expected
Just want to write data to firestore