-
Notifications
You must be signed in to change notification settings - Fork 930
onAuthStateChange or persist no longer works on react native expo apps!!!! #7152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Also happens on normal react. |
|
Hi thesoicalapp91, thanks for reporting. This may be similar to #6732 and #6050. Can you try upgrading to v9 modular and see if the issue still happens? |
Hi NhienLam, both unfortunately. I used compat for my old project that was running on my mac Catalina. I then bit the bullet with a complete system update to Ventura for the specific reason of creating a new npx-create-expo-app with all the latest SDK's, setup etc and specifically to fix the firebase issue however, the new v9 code does not work on my completely new Ventura system set up either (in a new npx-create-expo-app not my old app). And yes, it seams to be the same issue as #6732 and #6050. I'm going to give #6050 a try. |
Checked out the other issues but not really a proper fix... Added a storage token await layer, now getting the token, but sign out and token removal stops working. A user can log out and anyone can log back using incorrect credentials as the token stays around. Tried adding basic state hooks but I cant spend any more time on this today. Will try again during the week. Bit annoying really... |
Thanks for the update @thesoicalapp91. Can you share some code snippets after upgrading to v9 modular, for how you are using async storage? |
Thanks with help from #7164 I've managed to fix this and put a link to my answer: The steps to fix this are: Versions "expo": "~48.0.6", "react": "18.2.0", npm i firebase npm i @react-native-async-storage/async-storage npm i @react-native-firebase/auth Create a firebaseConfig.js file import AsyncStorage from "@react-native-async-storage/async-storage"; export const firebaseApp = initializeApp({ export const auth = initializeAuth(firebaseApp, { Create App.js import {StyleSheet} from 'react-native'; const App = () => { const styles = StyleSheet.create({ export default App; Create AppMain.js import { useEffect, useState } from 'react'; import { signInWithEmailAndPassword, onAuthStateChanged, signOut } from "firebase/auth"; const { width, height } = Dimensions.get('window'); export default function App() { useEffect(() => { const handleLogin = () => { const handleLogout = () => { if (!user) { if (user) { ); }; }; const styles = StyleSheet.create({ The following steps should keep the user logging in after refreshing the app. It also handles the sign in and sign out functions. This issue was bugging me for a while :). |
Hi NhienLam - I've added an answer above with my stack overflow answer link. It's fixed for me so this can be closed from my point of view. Thanks for the help. |
Hi [isaacrowntree], Try the steps above and in : https://stackoverflow.com/questions/75669669/how-to-persist-firebase-user-auth-on-react-native/75898568#75898568 |
Please fix this issue asap! Google, github, chatGPT nobody can get the user to stay logged in after refreshing the app in version 9!!!!!!! Please fix this and give the code example documentation!!! "Persist" dose not work on react native apps built with npx create-expo-app.
The text was updated successfully, but these errors were encountered: