I’m trying to set up basic authentication in my Next App with Firebase and firebase hooks.
Whenever I pass the firebase.auth() instance to the hook
import {useAuthState} from 'react-firebase-hooks/auth'
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
export default function App({ Component, pageProps }: AppProps) {
const [user] = useAuthState(firebase.auth())
return <Component {...pageProps} />
}}
I receive the error below
Argument of type 'firebase.default.auth.Auth' is not assignable to parameter of type '
import("[PROJECT_PATH]/node_modules/@firebase/auth/dist/auth-public").Auth'.
Property 'beforeAuthStateChanged' is missing in type 'firebase.default.auth.Auth'
but required in type [PROJECT_PATH]/node_modules/@firebase/auth/dist/auth-public").Auth
My guess is that react-firebase-hooks
needs an update so as of now I’m going to typecast as any
but if anyone has deeper insight I’d love to hear
2
Answers
firebase.auth()
gets the Auth service. Instead, what you should pass is the Auth instance. something like thisYou can always use following format to have a loading and error variable:
This helps to understand when to use user.