I'm new to ReactJs. I'm trying to create a firebase app using it. So in componentWillMount I'm checking if the user is logined or not and setting the state boolean value according to that
componentWillMount() {
var config = {...};
Firebase.initializeApp(config)
Firebase.auth().onAuthStateChanged(function(user){
if(user){
console.log("User logined");
this.setState({
isLogined : true
})
}else{
console.log("User isn't logined");
this.setState({
isLogined : false
})
}
})
}
But it's showing setState() is not a function.
index.js:2178 TypeError: this.setState is not a function
at Object.next (App.js:31)
at index.cjs.js:1353
at index.cjs.js:1457
Need Help :(