React native - reboot do nothing

I just started with React Native. I have a smartphone connected, and after that react-native run-androidI see "Hello World" on the screen. But when I change “Hello World” to something else, save the file, and then click on the reboot command on my device (after shaking the phone), I don’t see any changes. I need react-native run-androidto see new things again. I am working on Windows 10. In addition, the assembly takes a lot of time. I read similar things, but did not find a reasonable solution. Can anyone help?

Also: Sometimes, when I click Reload, I need to press enter in the terminal of the packer server to reload the view, but the changes are not displayed.

+4
source share
1 answer

I had the same problem and I found several solutions. The following works for me:

To enable reboot with versions <0.25

  • go to file: yourProjectFolder//node_modules/react-native/local-cli/server/server.js
    • Mark the line (62): process.exit (11) -> //process.exit(11)

About paragraph 2: I'm not sure when the solution is 2.1., But I think ~ react-native v.33. Please correct this if someone knows for sure. For you, just see if index.js is found in 2. or 2.1. way.

  • 2.1 ( Old path to the FileWatcher index.js file ) Go to the file:yourProjectFolder//node_modules/react-native/node_modules\node-haste\lib\FileWatcher\index.js"

  • 2.2 ( New path to FileWatcher index.js file ) Go to file:yourProjectFolder\node_modules\react-native\packager\react-packager\src\node-haste\FileWatcher\index.js

STEP 1 for 2.1 + 2.2:

  • Increaseat the top of the file index.js: MAX_WAIT_TIME=120000>MAX_WAIT_TIME=360000
  • Change function (_createWatcher)to:

2 2.1 ( 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.imtqy.com/watchman/docs/troubleshooting.html',
                ].join('\n')));
        }, MAX_WAIT_TIME);

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

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.imtqy.com/watchman/docs/troubleshooting.html',
          ].join('\n')));
        }, MAX_WAIT_TIME);

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

. , , .

+2

Source: https://habr.com/ru/post/1659008/


All Articles