This project is a minimal bare React Native repro for the React Navigation WeakRef crash in nested navigation.
- Install dependencies:
npm install- Confirm Android is using legacy architecture (this is required for the missing
WeakRefruntime):
android/gradle.propertiescontainsnewArchEnabled=false
- Start Metro in one terminal:
npm start- Run Android in another terminal:
npm run androidBy 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';- Open the app.
- Go to the
Othertab. - Tap
Navigate to nested stack screen.
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.
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.