From a4030b5906d47d12df74d02088fb12ee1f2380c1 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Mon, 25 Nov 2024 08:40:39 +0100 Subject: [PATCH] fix: use UIManager exported from react-native (#511) * fix: use UIManager exported from react-native * chore: add comment --- javascript/utils/index.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/javascript/utils/index.ts b/javascript/utils/index.ts index 1f529d38e..af3f09856 100644 --- a/javascript/utils/index.ts +++ b/javascript/utils/index.ts @@ -5,14 +5,11 @@ import { findNodeHandle, Platform, ImageSourcePropType, + UIManager, } from "react-native"; -function getAndroidManagerInstance(module: string): any { - const haveViewManagerConfig = - NativeModules.UIManager && NativeModules.UIManager.getViewManagerConfig; - return haveViewManagerConfig - ? NativeModules.UIManager.getViewManagerConfig(module) - : NativeModules.UIManager[module]; +function getAndroidManagerInstance(module: string) { + return UIManager.getViewManagerConfig(module); } function getIosManagerInstance(module: string): any { @@ -84,11 +81,14 @@ export function runNativeCommand( } if (isAndroid()) { - return NativeModules.UIManager.dispatchViewManagerCommand( + UIManager.dispatchViewManagerCommand( handle, managerInstance.Commands[name], args, ); + + // Android uses callback instead of return + return null as ReturnType; } return managerInstance[name](handle, ...args); @@ -125,6 +125,7 @@ export function getIOSModuleName(moduleName: string): string { if (moduleName.startsWith("RCT")) { return moduleName.substring(3); } + return moduleName; }