Skip to content

fix(mobile): prevent FlashList unmount crash on station change - #754

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/better-rail-37-flashlist-crash
Open

fix(mobile): prevent FlashList unmount crash on station change#754
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/better-rail-37-flashlist-crash

Conversation

@sentry

@sentry sentry Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the IllegalStateException: addViewAt crash occurring on Android in apps/mobile/src/screens/route-list/route-list-screen.tsx.

Root Cause:
The crash was caused by the FlashList being unmounted mid-navigation transition when the [originId, destinationId] effect called setRouteData([]) upon station changes. This led to React Native Fabric attempting to insert a view that was still attached to the outgoing fragment, triggering the addViewAt error. This was a regression, as a previous fix (PR #689) had already addressed this by keeping the list mounted.

Solution:
This fix restores the approach from PR #689:

  1. Removed setRouteData([]) from the [originId, destinationId] effect: The FlashList is no longer torn down when stations change, preventing the mid-transition unmount.
  2. Introduced routeDataStations state: This state now tracks the { originId, destinationId } for which the current routeData was fetched.
  3. Implemented replace-in-place logic in the trains.isSuccess effect: When new data arrives for different stations (detected by comparing with routeDataStations), routeData is now replaced entirely instead of being merged. routeDataStations is updated accordingly.
  4. Reset routeDataStations in the [time, hideSlowTrains] effect: Ensures that a full refresh (e.g., changing the date or filter) correctly clears the station tracking.

Fixes BETTER-RAIL-37

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f2909d99-29fe-49a5-8d56-2ecefb9423ab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

0 participants