399

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

10 Answers 10

627

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.

5
  • 6
    This video from RN website might help also. youtu.be/2uQzVi-KFuc Commented Jun 14, 2018 at 8:35
  • 10
    Why would anyone prefer live reloading over hot reloading? Is there any benefit to live reloading?
    – Jan
    Commented Jul 26, 2018 at 0:54
  • Can both be done in Kotlin? If so, can you please direct me to a decent resource? Peace!
    – monkSinha
    Commented Feb 28, 2019 at 23:40
  • Do these only work when running in Expo, or also from an ejected app? Commented Apr 5, 2019 at 3:20
  • 4
    @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. Commented Sep 8, 2019 at 2:34
16

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

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 it does not concern in which file change comes.

4

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.

2

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.

0

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

0

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.

0

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 Reloading Works?

  • When you make changes in your code, the React Native Packager will detect the changes 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 Reloading 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.

2
  • 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. Commented Jan 7, 2023 at 7:07
  • 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. Commented Jan 7, 2023 at 7:10
0

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.
-1

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:

  1. Live Reloading:

    • How it works: When you make changes to your code and save the file, the entire app is recompiled, and the entire state of the app is reset. Then, the app is reloaded from the beginning.
    • Pros:
      • Simple and straightforward.
      • Useful for scenarios where the application state is not easily reproducible or when there are significant changes that require a full reset.
    • Cons:
      • Can be slower, especially for large applications, as it involves a full app reload.
      • May lose the current state of the application, making it less suitable for certain scenarios.
  2. Hot Reloading:

    • How it works: Hot Reloading injects new versions of the files that you edited into the running app, allowing you to keep the app's current state while seeing the effects of your changes in real-time.
    • Pros:
      • Faster than Live Reloading because it only updates the changed modules instead of reloading the entire app.
      • Maintains the application state, making it more seamless for developers to see the impact of their changes without losing the current state of the app.
    • Cons:
      • It might not handle all types of changes perfectly, and some manual intervention may be required in certain cases.
      • Depending on the changes made, it might not always reflect the exact state of the application.

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.