我刚开始使用React Native.我连接了智能手机,在反应原生运行后,我可以在屏幕上看到“Hello World”.但是,当我将“Hello World”更改为其他内容时,保存文件,然后点击我设备上的重新加载命令(握手后),我看不到任何更改.我需要再次反应本机run-android以查看新内容.我正在使用Windows 10.此外,构建需要花费大量时间.我读过类似的东西,但没有找到任何合理的解决方案.有人可以帮忙吗?
另外:有时当我点击重新加载时,我需要在包装器服务器终端中输入,重新加载视图,但不会出现更改.
使用> 0.29 react-native-versions启用生命重新加载
- go to file:
yourProjectFolder//node_modules/react-native/local-cli/server/server.js
- Commend the line (62): process.exit(11) -> //process.exit(11)
关于第2点:我不确定自2.1的解决方案.需要,但我认为〜反应原生v.33.如果有人确切知道,请更正此问题.如果您在2.或2.1处找到index.js,请查看.路径.
2.1 (Older Path of React-Native FileWatcher index.js) Go to file:
yourProjectFolder//node_modules/react-native/node_modules\node-haste\lib\FileWatcher\index.js"
2.2 (Newer Path of React-Native FileWatcher index.js) Go to file:
yourProjectFolder\node_modules\react-native\packager\react-packager\src\node-haste\FileWatcher\index.js
2.1的步骤1 2.2:
>在index.js文件的顶部增加:MAX_WAIT_TIME = 120000> MAX_WAIT_TIME = 360000
>将函数(_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);
});
});
}
步骤2 for 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',function () {
clearTimeout(rejectTimeout);
resolve(watcher);
});
});
}
这个解决方案对我有用.希望如果我错了,我可以帮助你并纠正我.