Skip to content

wuppious/react-navigation-weak-ref-repro

Repository files navigation

WeakRef Repro Steps

This project is a minimal bare React Native repro for the React Navigation WeakRef crash in nested navigation.

Setup

  1. Install dependencies:
npm install
  1. Confirm Android is using legacy architecture (this is required for the missing WeakRef runtime):
  • android/gradle.properties contains newArchEnabled=false
  1. Start Metro in one terminal:
npm start
  1. Run Android in another terminal:
npm run android

Reproduce crash (without workaround)

By default, this project already runs in a runtime where WeakRef is unavailable (Legacy Architecture). If your environment unexpectedly has WeakRef, you can optionally force it missing in index.js:

(globalThis as any).WeakRef = undefined;

Keep the polyfill disabled in index.js:

// import './weakRefPolyfill';
  1. Open the app.
  2. Go to the Other tab.
  3. Tap Navigate to nested stack screen.

Expected crash in repro

The app crashes because nested navigation consumes params in @react-navigation/core and calls new WeakRef(...) in a runtime where WeakRef is missing:

In this repo, missing WeakRef is the default runtime behavior. The forcing line in index.js is optional.

Verify workaround

In index.js, enable the startup polyfill:

import './weakRefPolyfill';

Recommended state:

// (globalThis as any).WeakRef = undefined;
import './weakRefPolyfill';

With the same navigation steps, the app should no longer crash, and you should see a warning log from the polyfill on startup.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors