React native - reload什么都不做

krz*_*hub 6 android react-native

我刚开始使用React Native.我连接了智能手机,之后react-native run-android我可以在屏幕上看到"Hello World".但是,当我将"Hello World"更改为其他内容时,保存文件,然后点击我设备上的重新加载命令(握手后),我看不到任何更改.我需要react-native run-android再次看到新事物.我正在使用Windows 10.此外,构建需要花费大量时间.我读过类似的东西,但没有找到任何合理的解决方案.有人可以帮忙吗?

另外:有时当我点击时,Reload我需要在包装器服务器终端中输入,重新加载视图,但不会出现更改.

Jon*_*wag 3

我遇到了同样的问题并找到了几种解决方案。以下内容对我有用:

使用>0.29的react-native-versions启用生命重载

  1. 转到文件:yourProjectFolder//node_modules/react-native/local-cli/server/server.js
    • 推荐第 (62) 行: process.exit(11) -> //process.exit(11)

关于第2点:我不确定从什么时候开始2.1的解决方案。是需要的,但我认为〜react-native v.33。如果有人确切知道的话请纠正。你只需查看是否在 2. 或 2.1 处找到了 index.js。小路。

  • 2.1(React-Native FileWatcher index.js 的旧路径)转到文件:yourProjectFolder//node_modules/react-native/node_modules\node-haste\lib\FileWatcher\index.js"

  • 2.2(React-Native FileWatcher index.js 的较新路径)转到文件: yourProjectFolder\node_modules\react-native\packager\react-packager\src\node-haste\FileWatcher\index.js

2.1 + 2.2 的步骤 1:

  • Increase在文件顶部index.jsMAX_WAIT_TIME=120000>MAX_WAIT_TIME=360000
  • 改成function (_createWatcher)

2.1 的步骤 2(index.js 的旧路径)

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);
        });
    });
}
Run Code Online (Sandbox Code Playgroud)

2.2 的步骤 2(index.js 的较新路径)

_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);
        });
    });
}
Run Code Online (Sandbox Code Playgroud)

这个解决方案对我有用。希望我能帮助你并纠正我,如果我错了。