question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash app, TypeError: null is not an object (evaluating 'state.routes'), ReactNavigationV4Instrumentation

See original GitHub issue

Thanks, committers!

Environment

System:
    OS: macOS 10.15.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 43.17 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.22.0 - ~/.anyenv/envs/nodenv/versions/10.22.0/bin/node
    Yarn: 1.22.4 - ~/work/voice-memo-chat/node_modules/.bin/yarn
    npm: 6.14.6 - ~/.anyenv/envs/nodenv/versions/10.22.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 23, 25, 26, 27, 28, 29, 30
      Build Tools: 23.0.1, 23.0.2, 25.0.0, 26.0.1, 26.0.3, 27.0.3, 28.0.2, 28.0.3, 29.0.0, 29.0.2, 30.0.0, 30.0.0, 30.0.2, 30.0.3
      System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-Q | Google APIs Intel x86 Atom
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 12.4/12D4e - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0 
    react-native: 0.61.5 => 0.61.5

How do you use Sentry? Sentry SaaS (sentry.io) or self-hosted/on-premise (which version?) "@sentry/react-native": "^2.4.0",

Which SDK and version? e.g: JavaScript 5.11.1, .NET 1.2.0 "@sentry/react-native": "^2.4.0",

Steps to Reproduce

I am using it with react-navigation version4.

I noticed that when I run the navigate function, the app crashes. This problem is reproduced, for example, when I quickly tap the button twice to navigate to a particular screen.

The code we will try for the integration is as follows.

const routingInstrumentation = new Sentry.ReactNavigationV4Instrumentation();

Sentry.init({
  dsn: Config.SENTRY_DSN,
  tracesSampleRate: 0.2,
  integrations: [
    new Sentry.ReactNativeTracing({
      routingInstrumentation: routingInstrumentation,
      tracingOrigins: [
      ],
      // ... other options
    }),
  ],
});

<AppNavigator
  ref={(navigatorRef) => {
    routingInstrumentation.registerAppContainer(navigatorRef); //If remove this line, the problem will no longer occur.
  }}
>
</AppNavigator>

Actual Result

With the error in the issue title.

TypeError: null is not an object (evaluating 'state.routes')

ReactNavigationV4Instrumentation#_getCurrentRouteFromState
    reactnavigationv4.js:178:34
ReactNavigationV4Instrumentation#_onStateChange
    reactnavigationv4.js:117:60
_appContainer._navigation.router.getStateForAction
    reactnavigationv4.js:107:36
NavigationContainer#dispatch
    createAppContainer.js:351:8
actionHelpers.actionName
    getChildNavigation.js:1:1529
TouchableOpacity.props.onPress
    setting.js:247:45
createReactClass$argument_0.touchableHandlePress
    TouchableOpacity.js:264:45
touchableHandlePress
    [native code]:0
TouchableMixin._performSideEffectsForTransition
    Touchable.js:880:34
_performSideEffectsForTransition
    [native code]:0
TouchableMixin._receiveSignal
    Touchable.js:779:44
_receiveSignal
    [native code]:0
TouchableMixin.touchableHandleResponderRelease
    Touchable.js:490:24
touchableHandleResponderRelease
    [native code]:0
forEach
    [native code]:0
callFunctionReturnFlushedQueue
    [native code]:0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
jennmuengcommented, Apr 23, 2021

I will try to reproduce this

2reactions
jennmuengcommented, Sep 27, 2021

@liamjones I see this now, added to our immediate TODO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bountysource
Crash app, TypeError: null is not an object (evaluating 'state.routes'), ReactNavigationV4Instrumentation.
Read more >
TypeError: undefined is not an object (evaluating 'state.routes ...
Navigator and message is TypeError: undefined is not an object (evaluating 'state.routes.find') The part that causes the component exception is ...
Read more >
undefined is not an object evaluating navigation.navigate
It only happens here not in my other screens, is there a way to navigate to another screen, do you need to use...
Read more >
How To Fix TypeError null is not an object (evaluating ...
React Native Tutorial - This Video ShowsHow To Fix TypeError null is not an object ( evaluating 'dispatcher.useState) TypeError react native ...
Read more >
sentry Changelog - PyUp.io
fix: ReactNavigationV4Instrumentation null when evaluating 'state.routes' 1940 ... Fix crash when using Celery integration (`TypeError` when using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found