Skip to content

Conversation

kacperkapusciak
Copy link
Member

@kacperkapusciak kacperkapusciak commented Nov 10, 2021

Description

The Suspense mechanism in react-freeze sets display: none on a frozen screen. This sometimes results in an 'empty' screen when navigating between multiple screens at once (e.g. by using iOS back button menu).

This PR prevents showing frozen screen by making the display property on viewConfig.validAttributes.style not valid.

A detailed explanation can be found here

Thank you @grahammendick for this brilliant idea! 🙌

Fixes #1207

Test code and steps to reproduce

Test658, Test791, TestFreeze in TestsExample/ project

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

Copy link
Member

@WoLewicki WoLewicki left a comment

Choose a reason for hiding this comment

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

Looks good 🎉

@kacperkapusciak kacperkapusciak merged commit 616d3a2 into master Nov 15, 2021
@kacperkapusciak kacperkapusciak deleted the @kacperkapusciak/dont-set-display-none-on-frozen-screens branch November 15, 2021 13:05
kligarski added a commit that referenced this pull request Mar 13, 2025
…eens to work with RN 0.78 (#2778)

## 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.


https://github.com/user-attachments/assets/a371df20-d230-4e38-8770-022b72bacb6a


https://github.com/user-attachments/assets/8c3c9572-f77b-46ab-804c-d50361eeba06

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

- [x] Updated TS types
- [ ] Ensured that CI passes
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.

Pressing back fast on iOS may show frozen scene
2 participants