UnhandledLinkingContext throws while linking is not ready (!isLinkingReady branch omits providers)

Author: mtalhawahab099Created Mar 30, 2026Updated Aug 26, 2026
Labelsneeds repro

Problem

While NavigationContainer is in the “linking not ready” path (!isLinkingReady), it only renders LocaleDirContext + core ThemeProvider + fallback. It does not mount UnhandledLinkingContext.Provider or LinkingContext.Provider.

UnhandledLinkingContext’s default value throws if anything accesses lastUnhandledLink or setLastUnhandledLink. That can surface as:

Error: Couldn't find an UnhandledLinkingContext context.

during that window or when the gate flips again (e.g. toggling appearance / re-renders with async linking, portaled UI inside the container, etc.).

Expected behavior

Whenever NavigationContainer mounts (including the pre-resolution fallback branch), the same linking-related context values that exist after isLinkingReady should be available so consumers never hit the default context that throws.

Suggested fix

In the !isLinkingReady return path, wrap fallback with the same UnhandledLinkingContext.Provider and LinkingContext.Provider (and values unhandledLinkingContext / linkingContext) as in the main return, then keep ThemeProvider + fallback inside that tree.

Environment

  • @react-navigation/native: 7.x (e.g. 7.1.26)
  • React Native / Expo as applicable

Workaround

We applied a local patch-package change to lib/module/NavigationContainer.js to add those providers around the early-return branch.

Source: react-navigation/react-navigation