Skip to content

fix(core): Call onReady in NavigationContainer fallback path

fc3fa41
Select commit
Loading
Failed to load commit list.
Merged

feat(tracing): Add Sentry.NavigationContainer wrapper for React Navigation #6199

fix(core): Call onReady in NavigationContainer fallback path
fc3fa41
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden completed May 21, 2026 in 6m 56s

3 issues

Medium

Fallback `useEffect` re-calls `userOnReady` on every render when `onReady` is an unstable reference - `packages/core/src/js/NavigationContainer.tsx:69-73`

The useEffect at line 69 lists userOnReady as a dependency, so it re-fires—calling the user's onReady callback again—every time the parent re-renders with a new inline function reference, which is the common case.

Also found at:

  • packages/core/test/NavigationContainer.missing.test.tsx:42-48
  • samples/react-native-macos/src/App.tsx:172

Low

Fallback `useEffect` may re-invoke `onReady` on re-renders when `@react-navigation/native` is missing - `packages/core/src/js/index.ts:113`

In NavigationContainer.tsx the fallback useEffect (lines 71-75) lists userOnReady as a dependency and has no guard. When @react-navigation/native is not installed and the parent passes an inline onReady={() => …}, every parent re-render produces a new function reference, causing the effect to re-fire and invoke userOnReady repeatedly instead of once on mount. Consider capturing the callback in a ref and gating with a hasFired ref so it runs at most once, mirroring the real NavigationContainer.onReady semantics. Impact is limited because this only affects the missing-dependency fallback path, but it can surprise consumers who rely on onReady firing a single time.

Also found at:

  • packages/core/src/js/NavigationContainer.tsx:69-73
Module-level warning flags cause test order dependency - `packages/core/test/NavigationContainer.test.tsx:110-131`

The implementation's module-level _warnedNoClient and _warnedNoIntegration flags are set to true during the warning tests (lines 110–131) and are never reset between tests, so any future test in this file that re-enters those code paths won't see the expected warnings. Consider calling jest.resetModules() and re-importing in beforeEach, or exporting a reset helper for tests.

4 skills analyzed
Skill Findings Duration Cost
security-review 0 6.7s $0.16
code-review 2 6m 12s $1.12
find-bugs 1 5m 33s $1.70
gha-security-review 0 13.6s $0.08

⏱ 12m 5s · 863.9k in / 83.7k out · $3.06