Skip to content

Commit

Permalink
fix: use UIManager exported from react-native (#511)
Browse files Browse the repository at this point in the history
* fix: use UIManager exported from react-native
* chore: add comment
  • Loading branch information
KiwiKilian authored Nov 25, 2024
1 parent cab6e95 commit a4030b5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions javascript/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -84,11 +81,14 @@ export function runNativeCommand<ReturnType = NativeArg>(
}

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);
Expand Down Expand Up @@ -125,6 +125,7 @@ export function getIOSModuleName(moduleName: string): string {
if (moduleName.startsWith("RCT")) {
return moduleName.substring(3);
}

return moduleName;
}

Expand Down

0 comments on commit a4030b5

Please sign in to comment.