Skip to content

fix: Prevents Extra Screen Render when navigation index has not changed #35

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Zernach
Copy link

@Zernach Zernach commented May 6, 2025

What does this PR do?

  • This PR prevents the bottomsheet screen from being rendered a second time if the navigation index has not changed.

How should this be manually tested?

  • Add a console.log to any of your bottomsheet screens to track how many times the screen is rendered.
  • On the main branch, navigate to your bottomsheet screen, and you'll notice that the screen is being rendered twice, which inadvertently/unexpectedly dismisses the keyboard and clears the text input(s).
  • On this PR branch, you'll notice that the screen is only being rendered once (unless the navigation index changes and it needs to render a second time).

Background Information

  • This issue was discovered when using @gorhom/bottom-sheet and I was able to trace the issue back to the react-navigation-bottom-sheet repository and fix it here in this PR.

❌ Before Video

BEFORE — Renders twice. The second render happens ~1 second after mount. The second render causes the entire screen to be re-rendered, which inadvertently/unexpectedly dismisses the keyboard and clears the text input(s).

Kapture.2025-05-06.at.11.30.09.mp4

✅ After Video

AFTER — Only renders when needed!

Kapture.2025-05-06.at.11.30.45.mp4

@Zernach Zernach changed the title [FIX] Prevents Extra Screen Render when navigation index has not changed fix: Prevents Extra Screen Render when navigation index has not changed May 6, 2025
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.

1 participant