Unify "Hot Reloading" and "Reload-on-Save" into "Fast Refresh"

Summary:
We have too many options in the Dev Menu, and they're really hard to pick from. They're also somewhat conflicting. This replaces two menu choices that have a similar purpose (faster iteration cycle) with one.

"Fast Refresh" tries to only update the affected modules, but falls back to doing a full reload if the update can't be handled by the React components.

If for some reason you prefer the "Reload-on-Save" behavior, please:

- Reach out to me so I can learn more about your use case.
- As a workaround, you can add `if (__DEV__) require.Refresh.forceFullRefresh = true` to your app's entry point to always do a full refresh.

Also note that I only removed the user-facing part of "Reload-on-Save". So if you have automation depending on it, that's gonna keep working.

I moved it above Systrace since it's a more generic feature.

As a total aside nit, I renamed "Enable Inspector" and "Disable Inspector" to "Show Inspector" and "Hide Inspector" because... that's what those options do, really.

Reviewed By: rickhanlonii

Differential Revision: D15958697

fbshipit-source-id: 20e856d56f661fe4d39b5ab47d8c44754bf70f67
This commit is contained in:
Dan Abramov
2019-06-24 13:54:39 -07:00
committed by Facebook Github Bot
parent 0cb512f536
commit a52e6d1dbb
8 changed files with 64 additions and 47 deletions
@@ -32,7 +32,9 @@ public class DevInternalSettings implements
private static final String PREFS_JS_BUNDLE_DELTAS_KEY = "js_bundle_deltas";
private static final String PREFS_JS_BUNDLE_DELTAS_CPP_KEY = "js_bundle_deltas_cpp";
private static final String PREFS_ANIMATIONS_DEBUG_KEY = "animations_debug";
private static final String PREFS_RELOAD_ON_JS_CHANGE_KEY = "reload_on_js_change";
// This option is no longer exposed in the dev menu UI.
// It was renamed in D15958697 so it doesn't get stuck with no way to turn it off:
private static final String PREFS_RELOAD_ON_JS_CHANGE_KEY = "reload_on_js_change_LEGACY";
private static final String PREFS_INSPECTOR_DEBUG_KEY = "inspector_debug";
private static final String PREFS_HOT_MODULE_REPLACEMENT_KEY = "hot_module_replacement";
private static final String PREFS_REMOTE_JS_DEBUG_KEY = "remote_js_debug";
@@ -471,16 +471,19 @@ public class DevSupportManagerImpl implements
mReactInstanceManagerHelper.toggleElementInspector();
}
});
options.put(
mDevSettings.isReloadOnJSChangeEnabled()
? mApplicationContext.getString(R.string.catalyst_reload_on_save_stop)
: mApplicationContext.getString(R.string.catalyst_reload_on_save),
new DevOptionHandler() {
@Override
public void onOptionSelected() {
mDevSettings.setReloadOnJSChangeEnabled(!mDevSettings.isReloadOnJSChangeEnabled());
}
});
// "Live reload" which refreshes on every edit was removed in favor of "Fast Refresh".
// While native code for "Live reload" is still there, please don't add the option back.
//
// If for some reason you really need a full reload on every edit,
// you can put this into your application entry point as an escape hatch:
//
// if (__DEV__) {
// require.Refresh.forceFullRefresh = true;
// }
//
// See D15958697 for more context.
options.put(
mDevSettings.isHotModuleReplacementEnabled()
? mApplicationContext.getString(R.string.catalyst_hot_reloading_stop)