Skip to content

Conversation

@grahammendick
Copy link
Owner

Originally prevented React Native hiding frozen screens in 5f63a07. Made the display an 'invalid prop' so that React Native didn't set it to none - if it's none then swiping back stops working because the swipe happens on native and the scene isn't there (also tabs break on iOS for similar reasons).

But (think that) React Native 0.78 changed from diffProperties to fastAddProperties and setting validAttributes.display to false doesn't work anymore. It doesn't bail early. Changed to set it to null because that works for both diff and fastAdd functions - could even set it to display: {process: () => true} and that would work, too. (Wrongly thought the value determined whether it was a validAttribute but now think everything in the list is a validAttribute and the value determines what it's set to).

viewConfig.validAttributes.style = {
  ...viewConfig.validAttributes.style,
  display: null
};

Also updated fabric sample to React Native 0.78 to test

Tried running the current project but it wouldn't run?! so trying to update it
Doing this again after React Native 0.78 has broken it again. [Did it originally in commit 5f63a07](5f63a07) but back then think react native [called diffProperties](https://github.com/facebook/react-native/blob/1465c8f3874cdee8c325ab4a4916fda0b3e43bdb/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js#L1538) and that didn't set display to false if validAttributes.display returned false.
But now think [react native calls fastAddProperties](https://github.com/facebook/react-native/blob/33c0112b63c86fe2241c6ac19d242a46f4c5a301/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js#L1318) and that sets display to false if validAttributes.display returned false - now have to set to null instead so that it works for both old and new way.
Also could set to display: {process: () => true} and that would work for both - but that's more obscure and relies on going into the props setting logic rather than quickly bypassing upfront
Messed up local env a bit so suspect the Podfile lock isn't right. It's not needed anyway because running `bundle exec pod install` creates this, as well as the Gemfile.lock
It's fabric by default now
@grahammendick grahammendick merged commit 19dacce into master Feb 28, 2025
@grahammendick grahammendick deleted the rn-78 branch February 28, 2025 19:06
kligarski added a commit to software-mansion/react-native-screens 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
kkafar added a commit to software-mansion/react-native-screens that referenced this pull request Oct 22, 2025
## Description

~~No idea why the freeze worked up to 0.81, maybe there was something on
native side that prevented children from being unmounted and it is no
longer there. Our fix did not work, however. This commit fixes it.~~

~~Name of the filed has been changed here:~~

~~facebook/react-native@a36dbae48657965027e63c5bf90e4982af554581~~

@kligarski:

Starting from RN 0.82, our workaround that prevented unmounting frozen
views has stopped working - the bug is very similar to one described
[here](#2778).
The details of the workaround are available
[here](grahammendick/navigation#860).

Due to introduction of DOM APIs, `react-native` replaced
`ReactFabricHostComponent` with `ReactNativeElement`. This was hidden
behind a feature flag until [this
PR](facebook/react-native#53360) to RN 0.82. The
default value for `enableAccessToHostTreeInFabric` flag has been
switched to `true`.

In the workaround, we relied on internal value of `_viewConfig` which
has been renamed to `__viewConfig` in `ReactNativeElement`
implementation.

In this PR, we handle all names of this property.

| before | after |
| --- | --- |
| <video
src="https://github.com/user-attachments/assets/3cf7b785-a91a-4f13-beb3-b71aaabc17ca"
/> | <video
src="https://github.com/user-attachments/assets/a2bbdf01-d2a9-4808-9401-8ad12839a190"
/> |

Fixes
software-mansion/react-native-screens-labs#502.

## Changes

- add check for `__viewConfig` prop name in workaround

## Test code and steps to reproduce

Run `Test1726`. Go to screen 3 and go back via native back button.
Customization of back button on the second screen should be still
visible.

## Checklist

- [x] Included code example that can be used to test this change
- [ ] 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.

2 participants