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

fix(iOS): Fix conditional rendering on Fabric #1978

Closed
wants to merge 6 commits into from

Conversation

tboba
Copy link
Member

@tboba tboba commented Nov 27, 2023

Description

Currently when user tries to render screen conditionally the blank screen is being rendered.
That's because the screen after the changing state is being recycled, which leads to render UIReplicantView (which is the screen's snapshot) and not refresh push view controllers.
This PR fixes that by resetting view to screen and setting push view controllers when screen is being recycled.
Unfortunately when I was creating this PR I observed several screen blinks during the change of the state. I believe that this could be fixed by introducing @WoLewicki's PR about making view recycling optional (see RN #35378).

Closes #1628.

Changes

  • Added a conditional in mountChildComponentView that indicates if rendered screen was recycled
  • Added an option to force setPushViewControllers when arrays are the same

Screenshots / GIFs

Before 😥

Screen.Recording.2023-11-27.at.11.57.37.mov

After 🤯

Screen.Recording.2023-11-27.at.11.55.08.mov

Test code and steps to reproduce

You can check TestX included in this PR to check the changes.

Checklist

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

@tboba tboba requested review from WoLewicki and kkafar November 27, 2023 10:58
ios/RNSScreenStack.mm Outdated Show resolved Hide resolved
@snown
Copy link

snown commented Dec 12, 2023

After manually applying these changes to main, the application crashes on unmount throwing the 'Attempt to unmount a view which is mounted inside different view.' assert (somewhere around here).

I verified that a similar situation occurs where the screenChildComponent.controller.view is not of class RNSScreenView, and skipping that assert in that situation helps, but then the app sometimes crashes in other areas, when navigatin between regular screens.

@karimb11
Copy link

karimb11 commented Feb 12, 2024

Any change this fix will be merged? issue reported here #1628 still occurs.

Thanks 🙏

@tboba
Copy link
Member Author

tboba commented Mar 20, 2024

Superseded by #2069.

@tboba tboba closed this Mar 20, 2024
@tboba tboba deleted the @tboba/fix-conditional-rendering branch March 20, 2024 15:50
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.

Conditional rendering of a screen shows a blank screen (new arch)
4 participants