Created
June 2, 2023 04:55
-
-
Save keith-kurak/62628e661dab6d5452d29a2f3a3bf5a5 to your computer and use it in GitHub Desktop.
Firebase RN auth persistence fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { initializeApp } from "firebase/app"; | |
import AsyncStorage from '@react-native-async-storage/async-storage'; | |
import { initializeAuth, getReactNativePersistence } from "firebase/auth" | |
const firebaseConfig = { | |
//.. | |
}; | |
// Initialize Firebase | |
const app = initializeApp(firebaseConfig); | |
const reactNativeLocalPersistence = | |
getReactNativePersistence({ | |
getItem(...args) { | |
// Called inline to avoid deprecation warnings on startup. | |
return AsyncStorage.getItem(...args); | |
}, | |
setItem(...args) { | |
// Called inline to avoid deprecation warnings on startup. | |
return AsyncStorage.setItem(...args); | |
}, | |
removeItem(...args) { | |
// Called inline to avoid deprecation warnings on startup. | |
return AsyncStorage.removeItem(...args); | |
}, | |
}); | |
initializeAuth(app, | |
{ | |
persistence: reactNativeLocalPersistence | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment