Skip to content

fix: update workaround preventing React Native from hiding frozen screens to work with RN 0.78 #2778

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

Merged
merged 2 commits into from
Mar 13, 2025

Conversation

kligarski
Copy link
Contributor

@kligarski kligarski commented Mar 13, 2025

Description

React Native sets display: 'none' for frozen screens - this behavior can become an issue, if you for example press back button twice very fast on iOS - frozen screen might still be invisible. The problem and its workaround suggested by @grahammendick can be seen in issue #1207. The workaround was introduced in PR #1208.

Recently, React Native 0.78 has changed the way of diffing props and the workaround stopped working. The details and a new workaround has been suggested by @grahammendick once again in issue #2753 and PR grahammendick/navigation#860.

This PR introduces the suggested workaround.

A big thank you to @grahammendick for figuring it out and suggesting the solution once again, appreciate it!

Furthermore, the new workaround fixes a bug with back button on the screen stack header on iOS. The bug was probably introduced with the update to 0.78. The back button would disappear and then reappear after a short delay with generic "Back" label instead of the screen name.

before_2778.mp4
after_2778.mp4

Fixes #2753.

Changes

  • change display: false to display: null,
  • change ViewConfig interface to allow null value.

Tests

Run TestFreeze example, click Go to Details twice and then click the back button in the header. The button behaves as expected, which was not the case before - the button would disappear and then reappear with a generic "Back" title.

Checklist

  • Updated TS types
  • Ensured that CI passes

@grahammendick
Copy link
Contributor

Nice. You're welcome 👍

@kligarski kligarski marked this pull request as ready for review March 13, 2025 14:19
@kligarski kligarski requested a review from kkafar March 13, 2025 14:19
Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

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

Looks great, thanks!

@kligarski kligarski merged commit 5e2416a into main Mar 13, 2025
1 of 3 checks passed
@kligarski kligarski deleted the @kligarski/prevent-rn-from-hiding-frozen-screens branch March 13, 2025 15:05
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.

Prevent React Native hiding frozen screens
3 participants