diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm index cebd66de36c..16c00ccda57 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm @@ -785,6 +785,10 @@ namespace facebook { return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, "reload", @selector(reload), args, count); } + static facebook::jsi::Value __hostFunction_NativeDevSettingsSpecJSI_reloadWithReason(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, "reloadWithReason", @selector(reloadWithReason:), args, count); + } + static facebook::jsi::Value __hostFunction_NativeDevSettingsSpecJSI_setHotLoadingEnabled(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, "setHotLoadingEnabled", @selector(setHotLoadingEnabled:), args, count); } @@ -816,6 +820,9 @@ namespace facebook { methodMap_["reload"] = MethodMetadata {0, __hostFunction_NativeDevSettingsSpecJSI_reload}; + methodMap_["reloadWithReason"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_reloadWithReason}; + + methodMap_["setHotLoadingEnabled"] = MethodMetadata {1, __hostFunction_NativeDevSettingsSpecJSI_setHotLoadingEnabled}; diff --git a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h index f04097fbb71..b8d73129514 100644 --- a/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +++ b/Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h @@ -739,6 +739,7 @@ namespace facebook { @protocol NativeDevSettingsSpec - (void)reload; +- (void)reloadWithReason:(NSString *)reason; - (void)setHotLoadingEnabled:(BOOL)isHotLoadingEnabled; - (void)setIsDebuggingRemotely:(BOOL)isDebuggingRemotelyEnabled; - (void)setProfilingEnabled:(BOOL)isProfilingEnabled; diff --git a/Libraries/NativeModules/specs/NativeDevSettings.js b/Libraries/NativeModules/specs/NativeDevSettings.js index 3a2df4cb455..a09d765501f 100644 --- a/Libraries/NativeModules/specs/NativeDevSettings.js +++ b/Libraries/NativeModules/specs/NativeDevSettings.js @@ -15,6 +15,7 @@ import * as TurboModuleRegistry from '../../TurboModule/TurboModuleRegistry'; export interface Spec extends TurboModule { +reload: () => void; + +reloadWithReason?: (reason: string) => void; +setHotLoadingEnabled: (isHotLoadingEnabled: boolean) => void; +setIsDebuggingRemotely: (isDebuggingRemotelyEnabled: boolean) => void; +setProfilingEnabled: (isProfilingEnabled: boolean) => void; diff --git a/Libraries/Utilities/DevSettings.js b/Libraries/Utilities/DevSettings.js index f88489c75b2..21b1ab8fd67 100644 --- a/Libraries/Utilities/DevSettings.js +++ b/Libraries/Utilities/DevSettings.js @@ -1,6 +1,9 @@ /** * Copyright (c) Facebook, Inc. and its affiliates. * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * * @format */ @@ -36,8 +39,12 @@ class DevSettings extends NativeEventEmitter { }); } - reload() { - NativeDevSettings.reload(); + reload(reason: string) { + if (typeof NativeDevSettings.reloadWithReason === 'function') { + NativeDevSettings.reloadWithReason(reason || 'Uncategorized from JS'); + } else { + NativeDevSettings.reload(); + } } // TODO: Add other dev setting methods exposed by the native module. diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DevSettingsModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DevSettingsModule.java index 3004f100a4d..e6227638ce8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DevSettingsModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/debug/DevSettingsModule.java @@ -52,6 +52,11 @@ public class DevSettingsModule extends ReactContextBaseJavaModule { } } + @ReactMethod + public void reloadWithReason(String reason) { + this.reload(); + } + @ReactMethod public void setHotLoadingEnabled(boolean isHotLoadingEnabled) { mDevSupportManager.setHotModuleReplacementEnabled(isHotLoadingEnabled);