javascripttypescriptfirebasereact-native

Cannot import `getReactNativePersistence` in `firebase@10.1.0`


I cannot import the getReactNativePersistence module from the firebase/auth. I'm using Typescript.

Importing the function as below was possible, but it didn't work when I updated the Firebase SDK from 9.22.0 to 10.1.0.

import { getReactNativePersistence } from "firebase/auth/react-native";

It seems like there is no firebase/auth/react-native anymore.

I also tried the following code, as the document indicates,

import { getReactNativePersistence } from "firebase/auth";

But it throws an error.

Module '"firebase/auth"' has no exported member 'getReactNativePersistence'.

I'm using Expo, which uses Metro as default.

This is my metro.config.js

// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');

module.exports = getDefaultConfig(__dirname);

How can I import getReactNativePersistence in firebase@10.1.0?


Solution

  • {
      "compilerOptions": {
        "paths": {
          "@firebase/auth": ["./node_modules/@firebase/auth/dist/index.rn.d.ts"]
        }
      },
      "extends": "expo/tsconfig.base"
    }
    

    Apparently, it is a typescript issue. Add the code above to your tsconfig.json file. This fix worked for me.