diff --git a/src/components/CellRendererComponent.tsx b/src/components/CellRendererComponent.tsx index e4e861a6..39dba774 100644 --- a/src/components/CellRendererComponent.tsx +++ b/src/components/CellRendererComponent.tsx @@ -1,11 +1,11 @@ import React, { useEffect, useMemo, useRef } from "react"; import { - findNodeHandle, LayoutChangeEvent, MeasureLayoutOnSuccessCallback, StyleProp, ViewStyle, } from "react-native"; +import { findNodeHandle } from "../utils"; import Animated, { runOnUI, useAnimatedStyle, diff --git a/src/components/NestableDraggableFlatList.tsx b/src/components/NestableDraggableFlatList.tsx index 15593527..0fbccbce 100644 --- a/src/components/NestableDraggableFlatList.tsx +++ b/src/components/NestableDraggableFlatList.tsx @@ -1,5 +1,6 @@ import React, { useRef, useState } from "react"; -import { findNodeHandle, LogBox } from "react-native"; +import { LogBox } from "react-native"; +import { findNodeHandle } from "../utils"; import Animated, { useDerivedValue, useSharedValue, diff --git a/src/utils.ts b/src/utils.ts index 7989006d..3c21eba5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,14 @@ import React from "react"; +import { findNodeHandle as reactNativeFindNodeHandle, Platform } from 'react-native'; // Fixes bug with useMemo + generic types: // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/37087#issuecomment-542793243 export const typedMemo: (c: T) => T = React.memo; + + +export function findNodeHandle(ref: any): number | null { + if(Platform.OS === "web") { + return ref && typeof ref === 'object' && 'current' in ref ? ref.current : ref + } + return reactNativeFindNodeHandle(ref) +}