Repository navigation
chore: Use React Navigation v8 Alpha - #630
Conversation
- 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.
|
No actionable comments were generated in the recent review.
|
| 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:
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: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull 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.
Comment @coderabbitai help to get the list of available commands.
- 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.
Why
Warning
Do not update
react-native-pager-viewto 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.
@ts-expect-errorcode.~0.43 MBbased on the prior implementation).Compared to our initial implementation:
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:
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
useNavigationState()selector function more.Vinyl (Legacy)design when rotating screen and restoring back to portrait.Checklist
pnpm sync:licenses.pnpm android:prod.Summary by CodeRabbit