What is the difference between Hot Reloading and Live Reloading in React Native?

不羁的心 提交于 2019-12-17 17:19:00

问题


I'm a bit confused here. When I'm debugging a React Native Application, I usually enable both Hot Reloading and Live Reloading. I want to know what is the difference between them?


回答1:


Live reloading reloads or refreshes the entire app when a file changes. For example, if you were four links deep into your navigation and saved a change, live reloading would restart the app and load the app back to the initial route.

Hot reloading only refreshes the files that were changed without losing the state of the app. For example, if you were four links deep into your navigation and saved a change to some styling, the state would not change, but the new styles would appear on the page without having to navigate back to the page you are on because you would still be on the same page.




回答2:


Both can be enabled using CMD+D / CMD+CTRL+Z / Shake Gesture menu. Both are using watchman to listen to the file changes.

Live reloading reloads the entire app.

The idea behind hot reloading is to keep the app running and to inject new versions of the files that you edited at runtime. This way, you don't lose any of your state which is especially useful if you are tweaking the UI. So it reloads only that page which you change more info here




回答3:


While developing React-Native app you need to view your code changes and for viewing code changes there is two options in React-Native.

  1. Hot Reload

    Hot reload just displays the code changes according to new code changes without restarting the app from start and it effects only on the changed code.

  2. Live Reload

    Sometimes we might need Live Reload to test our code like navigation so Live reload is helpful in that case so it will reloads the whole application on change in the code.




回答4:


Hot reload just displays the code changes according to new code changes without restarting the app from start and it effects only on the changed code. but its good when just styling the components when adding/changing JS code it creates problems. For that Live reload or rr works good



来源:https://stackoverflow.com/questions/41428954/what-is-the-difference-between-hot-reloading-and-live-reloading-in-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!