Skip to content

Commit 03a2322

Browse files
committed
add custom findNodeHandle impl for web & remove patch
1 parent 0717d3f commit 03a2322

6 files changed

Lines changed: 20 additions & 32 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const restrictedImportPaths = [
1414
'Text',
1515
'ScrollView',
1616
'Animated',
17+
'findNodeHandle'
1718
],
1819
message: [
1920
'',

patches/react-native-web+0.20.0+010+restore-findNodeHandle.patch

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
TextInputKeyPressEventData,
1313
TextInputScrollEventData,
1414
} from 'react-native';
15-
import {DeviceEventEmitter, findNodeHandle, InteractionManager, NativeModules, StyleSheet, View} from 'react-native';
15+
import {DeviceEventEmitter, InteractionManager, NativeModules, StyleSheet, View} from 'react-native';
1616
import {useFocusedInputHandler} from 'react-native-keyboard-controller';
1717
import type {OnyxEntry} from 'react-native-onyx';
1818
import {useAnimatedRef, useSharedValue} from 'react-native-reanimated';
@@ -59,6 +59,7 @@ import CONST from '@src/CONST';
5959
import ONYXKEYS from '@src/ONYXKEYS';
6060
import type * as OnyxTypes from '@src/types/onyx';
6161
import type ChildrenProps from '@src/types/utils/ChildrenProps';
62+
import findNodeHandle from '@src/utils/findNodeHandle';
6263

6364
type SyncSelection = {
6465
position: number;

src/pages/home/report/ReportActionItemMessageEdit.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import lodashDebounce from 'lodash/debounce';
22
import type {ForwardedRef} from 'react';
33
import React, {forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react';
4-
import {findNodeHandle, InteractionManager, View} from 'react-native';
4+
import {InteractionManager, View} from 'react-native';
55
import type {MeasureInWindowOnSuccessCallback, NativeSyntheticEvent, TextInput, TextInputFocusEventData, TextInputKeyPressEventData, TextInputScrollEventData} from 'react-native';
66
import {useFocusedInputHandler} from 'react-native-keyboard-controller';
77
import {useSharedValue} from 'react-native-reanimated';
@@ -46,6 +46,7 @@ import CONST from '@src/CONST';
4646
import ONYXKEYS from '@src/ONYXKEYS';
4747
import type * as OnyxTypes from '@src/types/onyx';
4848
import KeyboardUtils from '@src/utils/keyboard';
49+
import findNodeHandle from '@src/utils/findNodeHandle';
4950
import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu';
5051
import getCursorPosition from './ReportActionCompose/getCursorPosition';
5152
import getScrollPosition from './ReportActionCompose/getScrollPosition';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// eslint-disable-next-line no-restricted-imports
2+
import {findNodeHandle} from 'react-native';
3+
4+
export default findNodeHandle;

src/utils/findNodeHandle/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { Component, ComponentClass } from 'react';
2+
import type { NodeHandle } from 'react-native/Libraries/ReactNative/RendererProxy';
3+
4+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
5+
function findNodeHandle(componentOrHandle: null | number | Component<any, any> | ComponentClass<any>): null | NodeHandle {
6+
// eslint-disable-next-line no-console
7+
console.warn('findNodeHandle is not supported on web. Use the ref property on the component instead.');
8+
return null;
9+
}
10+
11+
export default findNodeHandle;

0 commit comments

Comments
 (0)