最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React Native Hot Reload doesn't update the screen on changes? - Stack Overflow

programmeradmin0浏览0评论

I've recently started working in React Native. I was intrigued by the Hot and Live reload features. However, hot reload isn't working for exactly how it should (instant change). I understand the difference between Hot Reload and Live Reload.

The problem is, whenever I make a change in my file, say profile.js, there's a tooltip saying Hot Reloading.., but the changes I made are not reflected. Now to be clear, I am just changing the font size of a TextView, which is inside the render function. However, if I go to another activity and then e back to profile.js, it reflects the changes.

Is there something I am doing wrong, or is it a bug in the Hot Reload feature?

Any links to other places where I could find answers are totally wele.

I've recently started working in React Native. I was intrigued by the Hot and Live reload features. However, hot reload isn't working for exactly how it should (instant change). I understand the difference between Hot Reload and Live Reload.

The problem is, whenever I make a change in my file, say profile.js, there's a tooltip saying Hot Reloading.., but the changes I made are not reflected. Now to be clear, I am just changing the font size of a TextView, which is inside the render function. However, if I go to another activity and then e back to profile.js, it reflects the changes.

Is there something I am doing wrong, or is it a bug in the Hot Reload feature?

Any links to other places where I could find answers are totally wele.

Share Improve this question asked Mar 29, 2018 at 10:10 Ajay GuptaAjay Gupta 2,0332 gold badges22 silver badges39 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

Hot reload will not work for all the cases. When there is a change which needs the whole bundle to rebuild, in that case it wont work. Small changes like text change, or any other trivial changes which doesn't require to build whole project should work just fine. For validating if its working or not.

  • Create a new project.
  • Enable hot reload but disable the live reload.
  • Change any text from the App.js file

Observe if there is any change in the screen or not. If it doesn't try upgrading the react native cli or reinstall.

It consumes me up to 2 working days. My app suddenly can't be hot reloaded.

I finally found the solution, the problem is with your watchman. So reinstall it:

rm -rf /usr/local/var/run/watchman && brew uninstall watchman && brew install watchman

I had similar problem, hot reloading wasn't working for home screen. At some point I've checked if it was working on other screens and it was fine there. After some tries of narrowing down the problem to particular thing I figured out that the HMR wasn't work because of if statement logic. My home screen was checking if user is logged in and depending on this it would load one or another ponent. I just made my ponent, on which I was working, as single screen rendered out of the current home screen and HMR worked perfect. Once I was done with it I've moved it back to home screen. This is not solution for every case, but in mine - it worked.

发布评论

评论列表(0)

  1. 暂无评论