Skip to content

chore: Use React Navigation v8 Alpha - #630

Merged
cyanChill merged 11 commits into
devfrom
chore/navigation-v8
Oct 24, 2026
Merged

cyanChill merged 11 commits into
devfrom
chore/navigation-v8

Conversation

@cyanChill

@cyanChill cyanChill commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Why

Warning

Do not update react-native-pager-view to v9 as the timing of its events is different, resulting in some issues.

This PR has us using the v8 alpha of React Navigation, based on our initial attempt in #542. We're doing a conversion and not using the new features such as data loaders.

  • One big improvement with the v8 alpha is that there's better type-safety with the exposed hooks, allowing us to remove some of our @ts-expect-error code.
  • It does also bundle in Material Symbols as a font, but we can exclude it since we won't use it (reduced the installed app size by ~0.43 MB based on the prior implementation).

Compared to our initial implementation:

  • We now take into account of the pre-loaded routes when accessing the navigation state.
  • We set inactiveBehavior = "none" due to the scrollbar not unmounting when the screen gets unfocused.

Pager View v9

We initially upgraded to Pager View v9, which it fixed the issues we noted in our initial attempt at conversion (when it was first released), but noticed a couple of issues on the MaterialTopTabs screen:

  • Navigating via swipe results in late navigation state updates.
  • If multi-select was enabled on "Tracks" screen and we swiped to the "Home" screen, it doesn't disappear until a little bit after the "Home" screen is fully visible.
  • Immediately using the back gesture when clicking the "Library" screen doesn't return us to the "Home" screen.
    • The navigation state does get set to "Home", but immediately returns to "Library".

When showing the native tab bar, we notice that the navigation state updates when the animation finishes, which resulted us in narrowing down the issue to the v9 implementation of Pager View. My current assumption is that when events are emitted changed between the 2 versions.

Other Changes

  • Utilize useNavigationState() selector function more.
  • Fix stale styles applied to vinyl in Vinyl (Legacy) design when rotating screen and restoring back to portrait.

Checklist

  • New files have the SPDX license identifier at the top of the file.
  • Documentation is up to date to reflect these changes.
  • Ensure dependency licenses are up-to-date by running pnpm sync:licenses.
  • This diff will work correctly for pnpm android:prod.

Summary by CodeRabbit

  • Bug Fixes
    • Improved navigation from recently played items and corrected active-screen detection in playback and multi-select features.
    • Updated navigation behavior to better handle inactive tabs.
  • Improvements
    • Updated the app’s navigation framework. These changes also strengthen route handling across library, search, playlist, and playback screens.

- We noted some issues in our initial attempt (unrecoverable blank screen in some scenarios, agressive scroll hijacking behavior), but we need to observe more.
  - https://redirect.github.com/callstack/react-native-pager-view/issues/1103
  - https://redirect.github.com/callstack/react-native-pager-view/issues/1104#issuecomment-5481685775
  - dfe5bc2
- This increased the installed app size by `~1.33 MB`.
- We initially wanted to start off with the version we've used in #542, but we get a build error probably from using a newer Kotlin version or AGP v9.
- For screens that use `navigation.setParams()`, we typed the `useNavigation()` hook to be for the `Library` screen for better auto-completing.
- This fixes some weird issues on the `Library` screen due to using the React `Activity` API.
  - For example, the scrollbar doesn't get unmounted when we navigate to a different screen.
- Specifying the screen `useNavgation()` is for fixes the type issue most of the type.
- With the "Recently Played" screen, spreading the `linkInfo` object into `popTo` just doesn't work out, so we just manually deconstruct the results of `getMediaLinkContext` and just pass them in manually.
- We don't use preloaded routes, but if we did, doing `state.routes.at(-1)` will no longer return the most recent route.
- https://reactnavigation.org/docs/8.x/upgrading-from-7.x/#stack-navigation-state-shape-has-changed
- We noticed the following issues:
  - Navigation state updates very late when using swipe gestures for navigation.
  - Back gesture isn't respected when doing it quickly (ie: click "Library" and immediately do back gesture - the toolbar highlights the "Home" tab then the "Library" tab, so we still end up on the "Library" screen).
- On further investigation, we see that the navigation state updates when the native tabbar animation finishes (after commenting out the `tabBar={noop}`).
- ❗ This issue seems to be caused by Pager View v9 as it seems events get emitted at a different time (ie: it seems `onIndexChange` gets called once we lift our finger in the drag) .
- On screen rotation & restoration to portrait, the vinyl is slightly off-center.
- I think this might be due to returning an empty object in the animated styles, resulting in stale styles.
  - I initially though this was an issue with React Navigation v8 as I noted this in our initial attempt.
@cyanChill cyanChill added the enhancement New feature or request label Oct 24, 2026
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8c005a26-45a4-40a6-ba77-da51a4837e43
Commits

Reviewing files that changed from the base of the PR and between 1c4be07 and bd60edc.

Files ignored due to path filters: 1
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 20
  • mobile/@types/global.d.ts
  • mobile/package.json
  • mobile/scripts/licenses/licenseClarification.json
  • mobile/src/modules/insights/screens/RecentlyPlayedView.tsx
  • mobile/src/modules/media/multiSelect/components/TrackMultiSelectListeners.tsx
  • mobile/src/modules/search/screens/View.tsx
  • mobile/src/navigation/components/BottomActions/RootToolbar.tsx
  • mobile/src/navigation/components/BottomActions/useBottomActions.ts
  • mobile/src/navigation/routes.tsx
  • mobile/src/navigation/screens/LibraryView.tsx
  • mobile/src/navigation/screens/folders/View.tsx
  • mobile/src/navigation/screens/now-playing/View.tsx
  • mobile/src/navigation/screens/now-playing/components/Artwork.tsx
  • mobile/src/navigation/screens/now-playing/sheets/PlaybackOptionsSheet.tsx
  • mobile/src/navigation/screens/playlists/CreateView.tsx
  • mobile/src/navigation/screens/playlists/ModifyView.tsx
  • mobile/src/navigation/screens/tracks/sheets/TrackSheet.tsx
  • mobile/src/navigation/utils/linking.ts
  • mobile/src/resources/licenses.json
  • mobile/src/stores/Session/actions.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The mobile app upgrades React Navigation packages to 8.0.0 alpha releases, updates root and screen navigation types, and changes active-route checks and top-tab behavior.

Changes: Mobile navigation migration

Layer / File(s) Summary
Upgrade and root navigation types
mobile/@types/global.d.ts, mobile/package.json, mobile/scripts/licenses/licenseClarification.json, mobile/src/resources/licenses.json, mobile/src/navigation/utils/linking.ts, mobile/src/stores/Session/actions.ts
React Navigation packages and license records use 8.0.0 alpha versions. The root navigator, linking configuration, and navigateToArtist use updated navigation types.
Route-typed screen navigation
mobile/src/modules/insights/screens/RecentlyPlayedView.tsx, mobile/src/modules/search/screens/View.tsx, mobile/src/navigation/components/BottomActions/RootToolbar.tsx, mobile/src/navigation/screens/LibraryView.tsx, mobile/src/navigation/screens/folders/View.tsx, mobile/src/navigation/screens/now-playing/..., mobile/src/navigation/screens/playlists/...
Screen components use route-specific navigation typing. Recently played navigation passes the destination and config as separate arguments. The non-alternative vinyl layout returns an empty transform array.
Active-route and tab behavior
mobile/src/modules/media/multiSelect/components/TrackMultiSelectListeners.tsx, mobile/src/navigation/components/BottomActions/useBottomActions.ts, mobile/src/navigation/routes.tsx, mobile/src/navigation/screens/tracks/sheets/TrackSheet.tsx
Route checks use the route at the navigation state’s current index. The root tab navigator sets inactiveBehavior to "none".

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • MissingCore/Music#629: Changes the root route tree and library route parameters, which connect to this PR’s navigation type updates and route-specific calls.
Merge Risk: Minimal · up to bd60e

No identified issue blocks the navigation upgrade from merging after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 17 files. (3 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: upgrading the app to React Navigation v8 alpha.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 41.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 17 files. (3 skipped: 3 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@cyanChill
cyanChill marked this pull request as ready for review October 24, 2026 18:49
@cyanChill
cyanChill merged commit dccdb24 into dev Oct 24, 2026
1 check passed
@cyanChill
cyanChill deleted the chore/navigation-v8 branch October 24, 2026 18:57
@coderabbitai coderabbitai Bot mentioned this pull request Oct 26, 2026
2 of 4 tasks
cyanChill added a commit that referenced this pull request Nov 15, 2026
- Based off of latest conversion attempt in #630.
- Also included fixes from 5616254, where some navigation actions failed due to under-the-hood changes with React Navigation.
- In addition, we also fixed:
  1. Stale styles on screen rotation (bd60edc).
  2. The annoying TypeScript error when importing the CSS file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant