'Why is firebase.auth undefined

I am using React and Firebase. I am trying to check, wether the user is authenticated. I have initialized firebase in a firebase config file and therefore import firebase from the file:

import { firebase } from './utils/firebase';

Inside of this File I imported getAuth and everything else I then tried to check the logged in Status with the following code:

    const[isUserSignedIn, setIsUsersignedIn] = useState(true);

  var user = firebase.auth().currentUser;
    if(user) {
      return setIsUsersignedIn(true);
    }
    else{
      setIsUsersignedIn(false);
    }

But i receive the following Error:

> Uncaught TypeError: _utils_firebase__WEBPACK_IMPORTED_MODULE_0__.firebase.auth is not a function

Please help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source