I can not save data in the Firebase - React Native database. I have already installed and imported Firebase into the project, the code looks like this:
componentWillMount(){
var config = {
apiKey: "***************************",
authDomain: "configuracaofirebase-3a6ef.firebaseapp.com",
databaseURL: "https://configuracaofirebase-3a6ef.firebaseio.com",
projectId: "configuracaofirebase-3a6ef",
storageBucket: "configuracaofirebase-3a6ef.appspot.com",
messagingSenderId: "939162871117"
};
firebase.initializeApp(config);
}
salvarDados(){
var database = firebase.database();
database.ref("pontuacao").set("100");
}
render() {
return (
<View style={styles.container}>
<Button
onPress={ () => { this.salvarDados() } }
title="Salvar dados"
color="#841584"
accessibilityLabel="Salvar dados"
/>
<Text>Meu App</Text>
</View>
);
}
The componentWillMount
is working, it just does not work when I call the salvarDados
method, the following error appears: