fix(mobile): Stabilize native stack option updates#4037
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved ... You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit f356466. Configure here.
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>

Extracted from #3910.
Avoids redundant native-stack
setOptionsupdates during busy thread renders, preventing thePreventRemoveProvidermaximum-update-depth failure. Includes the matching patched-dependency lockfile update.Validation inherited from #3910:
vp checkand mobile native lint passed before the split. The full typecheck is currently blocked in this workspace by unavailable mobile dependencies (expo-blur,expo-quick-actions, and@tabler/icons-react-native).Note
Stabilize native stack option updates to prevent redundant
navigation.setOptionscallsoptionsSignatureto produce a stable string fingerprint of an options object, handling primitives, functions (via source), arrays, and objects with cycle detection and stable key ordering.stabilizeOptionFunctionsto replace function-valued options with stable wrapper references that always delegate to the latest implementation, preventing reference churn on re-renders.NativeStackScreenOptions, computes a signature of the stable options on each render and skips callingnavigation.setOptionsif the signature matches the previously applied one.navigation.setOptionsis now a no-op when options are semantically unchanged; function options are passed as persistent wrapper references rather than new closures each render.Macroscope summarized f3d9691.
Note
Medium Risk
Changes navigation header update timing for all native-stack screens; incorrect signature or wrapper logic could leave stale headers or miss legitimate option updates.
Overview
Stops redundant
navigation.setOptionson busy thread screens by treating semantically equal header options as unchanged, addressingPreventRemoveProvidermaximum-update-depth failures during re-renders.NativeStackScreenOptionsnow builds stable option objects viastabilizeOptionFunctions(stable wrapper identities for inline header factories while still calling the latest closures) and compares anoptionsSignature(deep structural hash with function source text and refs ignored) before applying.setOptionsruns only when that signature changes, not on every layout pass from fresh object literals.The
@react-navigation/native-stackpatch lockfile hash is updated to match the current patched dependency artifact.Reviewed by Cursor Bugbot for commit f3d9691. Bugbot is set up for automated code reviews on this repo. Configure here.