反应本机热重载刷新,但不更新更改 [英] React native hot reloading refreshes but not updating the changes
问题描述
我了解React的基础知识,并且做了一些个人的关于React的项目.现在,我从反应本地开始.
I know the basics of react, and did some of my personal projects on react. Now I am starting with react-native.
所以我创建了一个新项目并运行了run-android
命令.它完成了所有必需的处理并启动了模拟器(我正在使用Genymotion android模拟器),
So I created a new project and ran the run-android
command. It did all the required processing and launched the emulator ( I am using Genymotion android emulator),
react-native init AwesomeProject
cd AwesomeProject
react-native run-android
在那之后,我在模拟器中启用了热重装.打开项目并稍微更改代码.然后进入模拟器,我按了r(两次),它说fetching bundle
.但是我得到了同样的东西.一切都没有改变.更改不会更新.
After that in the emulator I enabled Hot reloading. Opened up the project and changed the code a bit. Then into the emulator, I pressed r (twice), it says fetching bundle
. But I get the same thing. Nothing is changed. The changes are not updated.
所以,我关闭了终端,然后再次运行相同的命令
So, I closed the terminal and again ran this same command
react-native run-android
然后...它显示了更改.我不知道这是怎么了.我看到了这篇文章,并认为可能帮助.但事实并非如此.
Then... it showed the changes. I have no idea what is wrong here. I saw this post and thought it might help. But it didn't.
我做错了什么?我正在使用本机0.30.0和节点v6.3.1.如果有帮助,我可以在Windows 7上运行nexus 6P作为Genymotion android仿真器.
What am I doing wrong? I am using react-native 0.30.0, and Node v6.3.1. If it helps I am on windows 7, and running a nexus 6P as the Genymotion android emulator.
推荐答案
回答我自己的问题. 这篇文章帮助了我.
Answering my own question. This post helped me.
在此文件\ node_modules \ react-native \ node_modules \ node-haste \ lib \ FileWatcher \ index.js
Inside this file \node_modules\react-native\node_modules\node-haste\lib\FileWatcher\ index.js
- 我必须增加
MAX_WAIT_TIME
(我的位置从120000变为360000). - 还必须更改
- I had to increase
MAX_WAIT_TIME
(mine I changed from 120000 to 360000). - Also had to change
此
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);
});
});
}
现在,在进行了此更改之后,我进行了任何代码更改,我什至不必两次按R键,它就会自动更改.我希望这可以帮助像我这样的菜鸟.谢谢.
Now after this changes, any code changes I make, I don't even have to press R twice, it automatically changes. I hope this might help a noob like me. Thank you.
这篇关于反应本机热重载刷新,但不更新更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!