LoginSignup
1
1

More than 5 years have passed since last update.

Setting a timer for a long period of timeのコンソールのwarnを非表示にする。

Last updated at Posted at 2018-09-18
> react-native -v
react-native-cli: 2.0.1
react-native: 0.55.4
> exp -V
56.0.0
Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.

https://github.com/facebook/react-native/issues/12981
アプリ側の画面に表示されるYellowBoxは上記のURLにある方法で消えるみたいだが、
コンソール側では消えないようす。
しかも、定期的に流れてくるから邪魔。

  constructor(props) {
    super(props)

    global.__old_console_warn = global.__old_console_warn || console.warn;
    global.console.warn = (...args) => {
      let tst = (args[0] || '') + '';
      if (tst.startsWith('Setting a timer')) {
        return;
      }
      return global.__old_console_warn.apply(console, args);
    };
  }

App.jsなどに記入し、無理やり非表示にする。

Expo.jsが同じことをisMounted()でやっていたのでパクってきた。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1