a7ul/react-native-exception-handler

null is not an object (evaluating 'ReactNativeExceptionHandler.setHandlerforNativeException')'

bogdanpk opened this issue · 13 comments

Hi guys,

setJSExceptionHandler is working fine (without setNativeExceptionHandler) , but when I use setNativeExceptionHandler, I can't even run my app (it throw error before even starting the app):

null is not an object (evaluating 'ReactNativeExceptionHandler.setHandlerforNativeException')'

I tried to build .apk, it also doesn't work. I tested it on Android.

This is my code where I implement react-native-exception-handler


import React, { useState, useEffect } from 'react';
import { MyContextProvider } from './context/Context'
import AppStart from './AppStart'
import { Root } from "native-base";
import './i18next/i18n'
import { MenuProvider } from 'react-native-popup-menu';

import {  Alert } from 'react-native';
import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exception-handler';

const errorHandler = (e, isFatal) => {
  if (isFatal) {
 
    Alert.alert(
        'Unexpected error occurred',
        `
        Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}
        We have reported this to our team ! Please close the app and start again!
        `,
      [{
        text: 'Close'
      }]
    );
  } else {
    console.log(e); // So that we can see it in the ADB logs in case of Android if needed
  }
};

setJSExceptionHandler(errorHandler, false);

 setNativeExceptionHandler((errorString) => {
   console.log(errorString);
}, false,); 

export default function App() {

  return (
    <MyContextProvider>
      <Root>
        <MenuProvider>
          <AppStart />
        </MenuProvider>
      </Root>
    </MyContextProvider>
  );
}

Any help?

Thank you

Getting this kind of issue with 'react-navigation' version 5. Do you guys need more details?

Any solution for this? I have the same problem.

We also encountered this problem, any idea?

You'll see this if the library is not linked natively. Make sure to link it and rebuild the app

Same here

Same here. Autolinking is not working or something

Don't forget to run pod install!

Still happening in 2022

pod install fix this bug for me

Hi, Same here. Any update?

Got same issue...anybody take care ? or this package to be deprecated?

Still happening in 2023!
With React Native 0.68 which have autolinking by default...