menu

Questions & Answers

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

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?

Comments:
2023-01-11 09:00:47
Question is outdated as of React Native 0.61. Hot Reload and Live Reload were merged into "Fast Refresh" - reactnative.dev/blog/2019/09/18/version-0.61
Answers(9) :

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

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.

Comments:
2023-01-11 09:00:47
This video from RN website might help also. youtu.be/2uQzVi-KFuc
2023-01-11 09:00:47
Why would anyone prefer live reloading over hot reloading? Is there any benefit to live reloading?
2023-01-11 09:00:47
Can both be done in Kotlin? If so, can you please direct me to a decent resource? Peace!
2023-01-11 09:00:47
Do these only work when running in Expo, or also from an ejected app?
2023-01-11 09:00:47
@Jan yes, generally hot reloading is preferable to live reloading. However, hot reloading is more complex to implement, and sometimes is not as reliable as live reloading.

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

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

NOTE: These two (hot reload and live relaod) features are merged in the 0.62 version of react-native as fast refresh and if you are using a version below then these two(hot reload and live reload) will be available.

You can explore this question for more information about fast refresh and hot reload Difference between hot reload and fast refresh in react-native

1. Hot Reload

Hot reload just displays the code changes according to new code changes without restarting the app from the start and its effects only on the changed code or change will only apply to a specific component.

NOTE: Hot reload will not work sometimes if you are deep in your navigation.

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 reload the whole application on change in the code.

The difference between the two is, Live Reloading is gonna reload your entire application. It's just gonna be like, okay, the file changed, reload the entire app. Hot Reloading is not gonna reload your entire application. It's just going to patch the code that was changed and keep the state in your app.

Hot Reload:

Hot reload is used to refresh only the file in which code is change

Live Reload:

Live Reload is used to refresh the whole app it does not concern in which file change comes.

Hot Reload: Hot reload is used to refresh only the file in which code is change Live Reload: Live Reload is used to refresh the whole app.

In React Native,

Hot Reloading:

  • It provide feature you to update the code of your app without losing the state of the app or manually refreshing the app. This is achieved by injecting the new code into the running app, rather than replacing the entire app.

How Hot Reloding Works?

  • When you make changes in your code, the React Native Packager will detect the change and send the updated code to the running app. The app will then apply the changes to the appropriate components & allowing you to see the changes in the app without losing the current state.

Live Reloading:

  • The action refreshes the entire app whenever you make a change to the code. This involves replacing the entire app with the updated code, which means that the app will need to be restarted and the existing state will be reset.

How Live Reloding Works?

  • When you make changes in your code, the React Native Packager will replace the existing code with the updated code to the running app. The app will reset the current state of the app.

Hot Reloading is generally faster and more convenient, but Live Reloading can be useful in certain situations.

Comments:
2023-01-11 09:00:47
Sometimes live reloading is not working properly or if you need to reset the state of the app, In that case Hot reloading is more convenient.
2023-01-11 09:00:47
Please note that hot reloading may not work in all cases, and you may need to use live reloading or manually refresh the app in certain situations.

In React Native Development, Hot Reloading and Live Reloading are two separate features used to improve the development experience by allowing developers to see changes in the app without manually rebuilding and re-deploying.

Hot Reloading: Hot Reloading is a feature that allows developers to make changes to the code of an app and see those changes reflected in the app without having to rebuild and re-deploy the app. Instead, this is done by injecting the new code into the running app and updating the relevant components. Hot Reloading is useful for making quick changes to the app and seeing the results immediately, such as fixing bugs, styling issues, or adding new functionality.

Live Reloading: Live Reloading is a feature that allows developers to make changes to the code of an app and see those changes reflected in the app without having to rebuild and re-deploy the app and refresh the app manually. This feature will automatically reload the app and update the screen without the need to refresh the application. Live Reloading is useful for developers who need to make more significant changes to the app and want to see the updated app without having to rebuild and re-deploy the app each time manually.

Both features are quite similar, but the main difference is that Hot Reloading updates the changes in the running code. In contrast, Live Reloading updates the code and refreshes the application.