1
I cannot save data in the Firebase database - React Native. I have already done the installation and import of Firebase in the project, the code is 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
this working out, only it doesn’t work when I call the method salvarDados
, appears the following error:
post your code, not photos of it, makes it easier to understand the problem
– kivul