Reputation: 4403
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?
Upvotes: 403
Views: 124373
Reputation: 297
Hot Reloading
What it does: Hot reloading allows you to inject new versions of the JavaScript code into the running React Native application without losing the state of the app.
How it works: It keeps the application running, and only updates the changed modules. The state of the app (such as the current screen, component states, etc.) is preserved during the update process.
Advantages
Faster updates: Since it only updates the changed modules, the update process is generally faster compared to a full reload.
Preserves state: The application state is retained, providing a seamless development experience.
Live Reloading
What it does: Live reloading refreshes the entire application when changes are detected, including the JavaScript code, assets, and styles. However, it does not preserve the state of the app.
How it works: It restarts the entire application, loading the new code and assets. This means that the application state is reset during the reload
Advantages:
Reflects all changes: Since it reloads the entire application, it ensures that all changes, including those outside the JavaScript code (e.g., assets, styles), are applied.
Simplicity: Live reloading is relatively straightforward and may be sufficient for certain development scenarios.
Choosing Between Them:
Hot Reloading: Preferred for its speed and ability to retain state. It's more convenient during development when you want to see the impact of your changes quickly without losing the current app state.
Live Reloading: Useful when you need to ensure that all changes, including those beyond the JavaScript code, are applied. However, it comes at the cost of losing the current app state with each reload.
Upvotes: 0
Reputation: 229
Hot Reloading and Live Reloading are both features in React Native that aim to improve the development experience by allowing developers to see the immediate impact of code changes without having to manually refresh the entire application. However, there are some differences between the two:
Live Reloading:
Hot Reloading:
In summary, Live Reloading resets the entire app and reloads it from scratch, while Hot Reloading injects the changed code while preserving the app's state. Hot Reloading is generally preferred during development because it offers a faster and more seamless experience without losing the current application state. However, developers might switch between these modes based on the nature of the changes they are making.
Upvotes: -1
Reputation: 1912
In React Native,
Hot Reloading:
How Hot Reloading Works?
Live Reloading:
How Live Reloading Works?
Hot Reloading is generally faster and more convenient, but Live Reloading can be useful in certain situations.
Upvotes: 0
Reputation: 11
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.
Upvotes: 0
Reputation: 723
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.
Upvotes: 13
Reputation: 3187
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.
Upvotes: 2
Reputation: 87
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.
Upvotes: 4
Reputation:
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
Upvotes: 0
Reputation: 705
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
Upvotes: 16
Reputation: 53711
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.
Upvotes: 631