'React Native Expo: setTimeout() not working on Android emulator

I have this extremely weird situation. I have this code:

  useEffect(() => {
    let timeout = undefined as NodeJS.Timeout | undefined;
    if (dismissAfter && visible) {
      timeout = setTimeout(() => { <--- This code get called, but all code inside it not being called
        alert("HELLO"); <--- This alert does not even get called
        setVisible(false);
      }, dismissAfter);
    }
    return () => { if (timeout) clearTimeout(timeout); }
  }, [dismissAfter, visible]);

The code is to clear a notification automatically if there is dismissAfter property. If I run on web browser this works fine, but not in Android Emulator.

What am I missing here? Is this bug?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source