@@ -26,7 +26,6 @@ import androidx.compose.runtime.mutableIntStateOf
2626import androidx.compose.runtime.mutableStateOf
2727import androidx.compose.runtime.remember
2828import androidx.compose.runtime.rememberCoroutineScope
29- import androidx.compose.runtime.rememberUpdatedState
3029import androidx.compose.runtime.saveable.rememberSaveable
3130import androidx.compose.ui.Modifier
3231import com.firebase.ui.auth.AuthException
@@ -180,15 +179,15 @@ fun PhoneAuthScreen(
180179 }
181180 }
182181
183- val authState by remember(authUI) { authUI.authStateFlow() }.collectAsState(AuthState .Idle )
182+ val currentAuthState = remember(authUI) { authUI.authStateFlow() }.collectAsState(AuthState .Idle )
183+ val authState by currentAuthState
184184 val isLoading = authState is AuthState .Loading
185185
186- // A cancelled attempt leaves its Loading behind, and that state outlives this composition on
187- // the process-scoped FirebaseAuthUI, so a freshly composed screen would inherit the spinner.
188- val currentAuthState by rememberUpdatedState(authState)
186+ // A cancelled Loading outlives this composition on the process-scoped FirebaseAuthUI, and
187+ // currentAuthState is re-remembered per authUI, so onDispose reads the right instance.
189188 DisposableEffect (authUI) {
190189 onDispose {
191- if (currentAuthState is AuthState .Loading ) {
190+ if (currentAuthState.value is AuthState .Loading ) {
192191 authUI.updateAuthState(AuthState .Idle )
193192 }
194193 }
0 commit comments