[android] React Native reload 重加载 失效解决方案【RN 0.29 or RN 0.32版本】

更新了一下RN版本,更新完了之后,发现不能通过Reload刷新了,好坑啊,好在终于找到了解决方案:

首先,找到这个文件:

” \node_modules\node-haste\lib\FileWatcher\index.js“ @0.29

“react-native/packager/react-packager/src/node-haste/FileWatcher/index.js”@0.32

然后,找到MAX_WAIT_TIME,把MAX_WAIT_TIME值改的大一些,比如改成360000

接下来,把以下代码

key: '_createWatcher',
    value: function _createWatcher(rootConfig) {
      var watcher = new WatcherClass(rootConfig.dir, {
        glob: rootConfig.globs,
        dot: false
      });

      return new Promise(function (resolve, reject) {
        var rejectTimeout = setTimeout(function () {
          return reject(new Error(timeoutMessage(WatcherClass)));
        }, MAX_WAIT_TIME);

        watcher.once('ready', function () {
          clearTimeout(rejectTimeout);
          resolve(watcher);
        });
      });
    }

替换成

key: '_createWatcher',
    value: function _createWatcher(rootConfig) {
      var watcher = new WatcherClass(rootConfig.dir, {
        glob: rootConfig.globs,
        dot: false
      });

      return new Promise(function (resolve, reject) {

        const rejectTimeout = setTimeout(function() {
          reject(new Error([
            'Watcher took too long to load',
            'Try running `watchman version` from your terminal',
            'https://facebook.github.io/watchman/docs/troubleshooting.html',
          ].join('\n')));
        }, MAX_WAIT_TIME);

        watcher.once('ready', function () {
          clearTimeout(rejectTimeout);
          resolve(watcher);
        });
      });
    }

就可以解决了

你可能感兴趣的:(RN,andriod,rn,error)