From 369e45ca1758c751d732813d7d3f80fc38b32b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bert?= <63123542+m-bert@users.noreply.github.com> Date: Fri, 1 Mar 2024 14:57:53 +0100 Subject: [PATCH] Move `customDirectEventTypes` to separate files. (#2786) ## Description `customDirectEventTypes` import inside `createHandler` introduced in #2766 makes web unable to compile since `react-native-web` doesn't provide this object. This PR moves mentioned import into separate file and splits it into `.ts` and `.web.ts` parts ## Test plan Tested on web and FabricExample app. --- src/handlers/createHandler.tsx | 3 +-- src/handlers/customDirectEventTypes.ts | 2 ++ src/handlers/customDirectEventTypes.web.ts | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 src/handlers/customDirectEventTypes.ts create mode 100644 src/handlers/customDirectEventTypes.web.ts diff --git a/src/handlers/createHandler.tsx b/src/handlers/createHandler.tsx index d33adefb43..a7e74ca5f5 100644 --- a/src/handlers/createHandler.tsx +++ b/src/handlers/createHandler.tsx @@ -5,8 +5,7 @@ import { DeviceEventEmitter, EmitterSubscription, } from 'react-native'; -// @ts-ignore - its taken straight from RN -import { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry'; +import { customDirectEventTypes } from './customDirectEventTypes'; // @ts-ignore - it isn't typed by TS & don't have definitelyTyped types import deepEqual from 'lodash/isEqual'; import RNGestureHandlerModule from '../RNGestureHandlerModule'; diff --git a/src/handlers/customDirectEventTypes.ts b/src/handlers/customDirectEventTypes.ts new file mode 100644 index 0000000000..3848dac64c --- /dev/null +++ b/src/handlers/customDirectEventTypes.ts @@ -0,0 +1,2 @@ +// @ts-ignore - its taken straight from RN +export { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry'; diff --git a/src/handlers/customDirectEventTypes.web.ts b/src/handlers/customDirectEventTypes.web.ts new file mode 100644 index 0000000000..b7867a663b --- /dev/null +++ b/src/handlers/customDirectEventTypes.web.ts @@ -0,0 +1,5 @@ +// customDirectEventTypes doesn't exist in react-native-web, therefore importing it +// directly in createHandler.tsx would end in crash. +const customDirectEventTypes = {}; + +export { customDirectEventTypes };