react-navigation / react-navigation/react-navigation

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

Open Beginner friendly
#13,051 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

needs repro
Dominant language
TypeScript
Stars
24.5k
Forks
5.1k
Avg merge
1d 5h
Merged PRs (30d)
18

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/module/NavigationContainer.js at the !isLinkingReady early-return branch, then compare it with the main return path and its UnhandledLinkingContext.Provider and LinkingContext.Provider values. Ensure the fallback uses the same linking-related providers and remains inside ThemeProvider; done means consumers no longer hit the throwing default context during pre-resolution renders.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
mobile
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.