diff --git a/Libraries/Utilities/HMRClient.js b/Libraries/Utilities/HMRClient.js index 9e02f9bf2e0..02013b480d1 100644 --- a/Libraries/Utilities/HMRClient.js +++ b/Libraries/Utilities/HMRClient.js @@ -46,7 +46,7 @@ const HMRClient = { const modules = (require: any).getModules(); if (_hmrClient.outdatedModules.size > 0) { let message = - "You've changed these files before turning on Hot Reloading: "; + "You've changed these files before turning on Fast Refresh: "; message += Array.from(_hmrClient.outdatedModules) .map(id => { @@ -72,7 +72,7 @@ const HMRClient = { _hmrClient.shouldApplyUpdates = false; }, - // Called once by the bridge on startup, even if hot reloading is off. + // Called once by the bridge on startup, even if Fast Refresh is off. // It creates the HMR client but doesn't actually set up the socket yet. setup( platform: string, @@ -106,7 +106,7 @@ const HMRClient = { _hmrClient = hmrClient; hmrClient.on('connection-error', e => { - let error = `Hot reloading isn't working because it cannot connect to the development server. + let error = `Fast Refresh isn't working because it cannot connect to the development server. Try the following to fix the issue: - Ensure that the packager server is running and available on the same network`; @@ -151,7 +151,7 @@ Error: ${e.message}`; hmrClient.on('update-start', () => { if (shouldProvideVisualFeedback()) { - HMRLoadingView.showMessage('Hot Reloading...'); + HMRLoadingView.showMessage('Refreshing...'); } }); @@ -182,13 +182,15 @@ Error: ${e.message}`; if (data.type === 'GraphNotFoundError') { hmrClient.disable(); + // TODO: this shouldn't be a redbox. setHMRUnavailableReason( - 'The packager server has restarted since the last Hot update. Hot Reloading will be disabled until you reload the application.', + 'The packager server has restarted since the last edit. Fast Refresh will be disabled until you reload the application.', ); } else if (data.type === 'RevisionNotFoundError') { hmrClient.disable(); + // TODO: this shouldn't be a redbox. setHMRUnavailableReason( - 'The packager server and the client are out of sync. Hot Reloading will be disabled until you reload the application.', + 'The packager server and the client are out of sync. Fast Refresh will be disabled until you reload the application.', ); } else { throw new Error(`${data.type} ${data.message}`); @@ -197,8 +199,9 @@ Error: ${e.message}`; hmrClient.on('close', data => { HMRLoadingView.hide(); + // TODO: this shouldn't be a redbox. setHMRUnavailableReason( - 'Disconnected from the packager server. Hot Reloading will be disabled until you reload the application.', + 'Disconnected from the packager server. Fast Refresh will be disabled until you reload the application.', ); }); diff --git a/React/Base/RCTBundleURLProvider.m b/React/Base/RCTBundleURLProvider.m index e7557674dfd..558e2da21e3 100644 --- a/React/Base/RCTBundleURLProvider.m +++ b/React/Base/RCTBundleURLProvider.m @@ -15,7 +15,9 @@ NSString *const RCTBundleURLProviderUpdatedNotification = @"RCTBundleURLProvider const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT; static NSString *const kRCTJsLocationKey = @"RCT_jsLocation"; -static NSString *const kRCTEnableLiveReloadKey = @"RCT_enableLiveReload"; +// 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: +static NSString *const kRCTEnableLiveReloadKey = @"RCT_enableLiveReload_LEGACY"; static NSString *const kRCTEnableDevKey = @"RCT_enableDev"; static NSString *const kRCTEnableMinificationKey = @"RCT_enableMinification"; @@ -74,12 +76,12 @@ static NSURL *serverRootWithHostPort(NSString *hostPort) - (BOOL)isPackagerRunning:(NSString *)host { NSURL *url = [serverRootWithHostPort(host) URLByAppendingPathComponent:@"status"]; - + NSURLSession *session = [NSURLSession sharedSession]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; __block NSURLResponse *response; __block NSData *data; - + dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); [[session dataTaskWithRequest:request completionHandler:^(NSData *d, @@ -90,7 +92,7 @@ static NSURL *serverRootWithHostPort(NSString *hostPort) dispatch_semaphore_signal(semaphore); }] resume]; dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); - + NSString *status = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; return [status isEqualToString:@"packager-status:running"]; } diff --git a/React/DevSupport/RCTDevMenu.m b/React/DevSupport/RCTDevMenu.m index 0b4d37b32c8..ee37aed7559 100644 --- a/React/DevSupport/RCTDevMenu.m +++ b/React/DevSupport/RCTDevMenu.m @@ -249,11 +249,20 @@ RCT_EXPORT_MODULE() } [items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{ - return devSettings.isElementInspectorShown ? @"Disable Inspector" : @"Enable Inspector"; + return devSettings.isElementInspectorShown ? @"Hide Inspector" : @"Show Inspector"; } handler:^{ [devSettings toggleElementInspector]; }]]; + if (devSettings.isHotLoadingAvailable) { + [items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{ + // Previously known as "Hot Reloading". We won't use this term anymore. + return devSettings.isHotLoadingEnabled ? @"Disable Fast Refresh" : @"Enable Fast Refresh"; + } handler:^{ + devSettings.isHotLoadingEnabled = !devSettings.isHotLoadingEnabled; + }]]; + } + if (devSettings.isLiveReloadAvailable) { [items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{ return devSettings.isDebuggingRemotely @@ -278,19 +287,17 @@ RCT_EXPORT_MODULE() } }]]; - [items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{ - return devSettings.isLiveReloadEnabled ? @"Disable Reload-on-Save" : @"Enable Reload-on-Save"; - } handler:^{ - devSettings.isLiveReloadEnabled = !devSettings.isLiveReloadEnabled; - }]]; - } - - if (devSettings.isHotLoadingAvailable) { - [items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{ - return devSettings.isHotLoadingEnabled ? @"Disable Hot Reloading" : @"Enable Hot Reloading"; - } handler:^{ - devSettings.isHotLoadingEnabled = !devSettings.isHotLoadingEnabled; - }]]; + // "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. } [items addObject:[RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{ diff --git a/React/Modules/RCTDevSettings.mm b/React/Modules/RCTDevSettings.mm index ef3cb7df488..c4f5870834b 100644 --- a/React/Modules/RCTDevSettings.mm +++ b/React/Modules/RCTDevSettings.mm @@ -18,7 +18,9 @@ static NSString *const kRCTDevSettingProfilingEnabled = @"profilingEnabled"; static NSString *const kRCTDevSettingHotLoadingEnabled = @"hotLoadingEnabled"; -static NSString *const kRCTDevSettingLiveReloadEnabled = @"liveReloadEnabled"; +// 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: +static NSString *const kRCTDevSettingLiveReloadEnabled = @"liveReloadEnabled_LEGACY"; static NSString *const kRCTDevSettingIsInspectorShown = @"showInspector"; static NSString *const kRCTDevSettingIsDebuggingRemotely = @"isDebuggingRemotely"; static NSString *const kRCTDevSettingExecutorOverrideClass = @"executor-override"; diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java index 8d64830a528..8777b64dac7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevInternalSettings.java @@ -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"; diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java index 60e24714d33..4808a9bd3ef 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java @@ -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) diff --git a/ReactAndroid/src/main/res/devsupport/values/strings.xml b/ReactAndroid/src/main/res/devsupport/values/strings.xml index 4b04fddbbc7..8aa02b7c5c1 100644 --- a/ReactAndroid/src/main/res/devsupport/values/strings.xml +++ b/ReactAndroid/src/main/res/devsupport/values/strings.xml @@ -10,12 +10,10 @@ Stop Chrome Debugging Debug with Nuclide Failed to communicate with the bundler to enabling debugging with Nuclide. - Enable Reload-on-Save - Disable Reload-on-Save - Enable Hot Reloading - Disable Hot Reloading - Disabling hot reloading because it requires a development bundle. - Switching to development bundle in order to enable hot reloading. + Enable Fast Refresh + Disable Fast Refresh + Disabling Fast Refresh because it requires a development bundle. + Switching to development bundle in order to enable Fast Refresh. Toggle Inspector Show Perf Monitor Hide Perf Monitor diff --git a/scripts/test-manual-e2e.sh b/scripts/test-manual-e2e.sh index 328f60f21d1..358a3d3de0c 100755 --- a/scripts/test-manual-e2e.sh +++ b/scripts/test-manual-e2e.sh @@ -92,7 +92,7 @@ grep -E "com.facebook.react:react-native:\\+" "${project_name}/android/app/build success "New sample project generated at /tmp/${project_name}" info "Test the following on Android:" -info " - Disable Hot Reloading. It might be enabled from last time (the setting is stored on the device)" +info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)" info " - Verify 'Reload JS' works" info "" info "Press any key to run the sample in Android emulator/device" @@ -101,12 +101,12 @@ read -n 1 cd "/tmp/${project_name}" && react-native run-android info "Test the following on iOS:" -info " - Disable Hot Reloading. It might be enabled from last time (the setting is stored on the device)" +info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)" info " - Verify 'Reload JS' works" info " - Test Chrome debugger by adding breakpoints and reloading JS. We don't have tests for Chrome debugging." info " - Disable Chrome debugging." -info " - Enable Hot Reloading, change a file (index.js) and save. The UI should refresh." -info " - Disable Hot Reloading." +info " - Enable Fast Refresh, change a file (index.js) and save. The UI should refresh." +info " - Disable Fast Refresh." info "" info "Press any key to open the project in Xcode" info ""