I am getting an error "undefined is not an object(evaluating "this.state.user") while calling login function through a button. the value of this.state.user is from use of onchangeText method. please help. the function is inside a firebase value event.
constructor(props) {
    super(props);
    this.state = { user: '', password: '' };
}
login = () => {
    db.ref('admins/').once('value', function(snapshot) {
        var user = snapshot.child('user_1').val();
        if (this.state.user == user) {
            this.props.navigation.navigate('FACULTYUI');
        }
    });
};
 
    