thebylito / react-native-navigation-bar-color

React Native component to change bottom bar/navigation bar color on Android
MIT License
269 stars 49 forks source link

Promise is unhandled (ERROR_NO_ACTIVITY) #36

Open djorkaeffalexandre opened 4 years ago

djorkaeffalexandre commented 4 years ago

Hey @thebylito, thanks about this library. I'm facing some bugs with the no attached activity, and this looks like a unhandled promise, but I'm surrounding this into a try/catch block. This looks that never reject the promise, just thrown a native error. Can you take a look? Thanks.

djorkaeffalexandre commented 4 years ago

@thebylito I just opened a PR with a fix. Thanks.

vtoupet commented 3 years ago

I also face the same issue.

function genMethod(moduleID: number, methodID: number, type: MethodType) {
  let fn = null;
  if (type === 'promise') {
    fn = function promiseMethodWrapper(...args: Array<any>) {
      // In case we reject, capture a useful stack trace here.
      const enqueueingFrameError: ExtendedError = new Error(); // CRASH OCCURS HERE
      return new Promise((resolve, reject) => {
        BatchedBridge.enqueueNativeCall(
          moduleID,
          methodID,
          args,

And in my code, I surround the code by try/catch:

  React.useEffect(() => {
    const changeColor = async (color: string, light: boolean) => {
      try {
        await changeNavigationBarColor(color, light, false);
      } catch (e) {}
    };