Skip to content

Commit c1b8a5b

Browse files
authored
Add older way to get UIManger constants (#1387)
1 parent 3456b38 commit c1b8a5b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/handlers/createHandler.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,15 @@ UIManager.genericDirectEventTypes = {
4343
...customGHEventsConfig,
4444
};
4545
// In newer versions of RN the `genericDirectEventTypes` is located in the object
46-
// returned by UIManager.getViewManagerConfig('getConstants'), we need to add it there as well to make
46+
// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make
4747
// it compatible with RN 61+
48-
if (UIManager.getViewManagerConfig) {
49-
UIManager.getViewManagerConfig('getConstants').genericDirectEventTypes = {
50-
...UIManager.getViewManagerConfig('getConstants').genericDirectEventTypes,
48+
const UIManagerConstants =
49+
UIManager.getViewManagerConfig?.('getConstants') ??
50+
UIManager.getConstants?.();
51+
52+
if (UIManagerConstants) {
53+
UIManagerConstants.genericDirectEventTypes = {
54+
...UIManagerConstants.genericDirectEventTypes,
5155
...customGHEventsConfig,
5256
};
5357
}

0 commit comments

Comments
 (0)