Skip to content
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

[No QA] fix: null check for app state subscription added #6936

Merged
merged 1 commit into from
Dec 29, 2021

Conversation

mananjadhav
Copy link
Collaborator

Details

  • Fixed the logout blank screen issue due to a missing null check.

Fixed Issues

$ #6932

Tests

QA Steps

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Mobile Web

Desktop

iOS

Android

@mananjadhav mananjadhav requested a review from a team as a code owner December 29, 2021 18:23
@MelvinBot MelvinBot requested review from TomatoToaster and removed request for a team December 29, 2021 18:23
@mananjadhav
Copy link
Collaborator Author

@TomatoToaster Before you merge, I would recommend checking the discussion on upgrading the RN in the linked issue.

@aldo-expensify
Copy link
Contributor

Also, if we want to merge this PR, it needs the CP Staging label, right?

@github-actions
Copy link
Contributor

⚠️ ⚠️ Heads up! This pull request has the CP Staging label. ⚠️ ⚠️
Merging it will cause it to be immediately deployed to staging, even if the open StagingDeployCash deploy checklist is locked.

@@ -26,6 +26,9 @@ function addBecameActiveListener(callback) {
}
const appStateChangeSubscription = AppState.addEventListener('change', appStateChangeCallback);
return () => {
if (!appStateChangeSubscription) {
return;
}
appStateChangeSubscription.remove();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code change still makes sense regardless right? It might be redundant with the RN upgrade if that makes it so appStateChangeSubscription is never null, but it wouldn't hurt to have this check.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dope then I think it's safe to merge!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I think including the null check is a good idea even in RN 0.65+, because, while unlikely, I think we could potentially have a race condition like this if a component mounts and unmounts almost instantly:

  1. Constructor initializes appStateChangeSubscription to null.
  2. Component mounts, componentDidMount runs and starts creating the subscription.
  3. Component unmounts and componentWillUnmount runs before componentDidMount finishes creating the subscription. So the subscription is still null 💥

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Thanks for the explanation :)

@TomatoToaster TomatoToaster merged commit b930390 into Expensify:main Dec 29, 2021
OSBotify pushed a commit that referenced this pull request Dec 29, 2021
[No QA] fix: null check for app state subscription added

(cherry picked from commit b930390)
@OSBotify
Copy link
Contributor

OSBotify commented Jan 4, 2022

🚀 Deployed to staging by @TomatoToaster in version: 1.1.24-19 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 failure ❌
🍎 iOS 🍎 failure ❌
🕸 web 🕸 failure ❌

@OSBotify
Copy link
Contributor

OSBotify commented Jan 4, 2022

🚀 Deployed to production by @francoisl in version: 1.1.24-19 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 failure ❌
🍎 iOS 🍎 failure ❌
🕸 web 🕸 failure ❌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants