Skip to content

Commit a8ed945

Browse files
authored
Merge pull request Expensify#67070 from software-mansion-labs/war-in/remove-findNodeHandle-patch
[NO QA] Add temporary custom `findNodeHandle` impl for web & remove patch
2 parents da97638 + d9d07e1 commit a8ed945

8 files changed

Lines changed: 29 additions & 45 deletions

File tree

.eslintrc.js

Lines changed: 5 additions & 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
'',
@@ -105,6 +106,10 @@ const restrictedImportPaths = [
105106
importNames: ['useOnyx'],
106107
message: "Please use '@hooks/useOnyx' instead.",
107108
},
109+
{
110+
name: '@src/utils/findNodeHandle',
111+
message: "Do not use 'findNodeHandle' as it is no longer supported on web.",
112+
},
108113
];
109114

110115
const restrictedImportPatterns = [

patches/react-native-web/details.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,7 @@
108108
- E/App issue: 🛑
109109
- PR introducing patch: https://github.com/Expensify/App/pull/60340
110110
111-
### [react-native-web+0.20.0+010+restore-findNodeHandle.patch](react-native-web+0.20.0+010+restore-findNodeHandle.patch)
112-
113-
- Reason:
114-
115-
```
116-
Changes `findNodeHandle()` to log a Console warning instead of throwing an Error when being called.
117-
```
118-
119-
- Upstream PR/issue: 🛑
120-
- E/App issue: 🛑
121-
- PR introducing patch: https://github.com/Expensify/App/pull/60421
122-
123-
### [react-native-web+0.20.0+011+fullstory-support.patch](react-native-web+0.20.0+011+fullstory-support.patch)
111+
### [react-native-web+0.20.0+010+fullstory-support.patch](react-native-web+0.20.0+010+fullstory-support.patch)
124112
125113
- Reason:
126114

patches/react-native-web/react-native-web+0.20.0+011+fullstory-support.patch renamed to patches/react-native-web/react-native-web+0.20.0+010+fullstory-support.patch

File renamed without changes.

patches/react-native-web/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: 3 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,8 @@ 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+
// eslint-disable-next-line no-restricted-imports
63+
import findNodeHandle from '@src/utils/findNodeHandle';
6264

6365
type SyncSelection = {
6466
position: number;

src/pages/home/report/ReportActionItemMessageEdit.tsx

Lines changed: 3 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';
@@ -45,6 +45,8 @@ import setShouldShowComposeInputKeyboardAware from '@libs/setShouldShowComposeIn
4545
import CONST from '@src/CONST';
4646
import ONYXKEYS from '@src/ONYXKEYS';
4747
import type * as OnyxTypes from '@src/types/onyx';
48+
// eslint-disable-next-line no-restricted-imports
49+
import findNodeHandle from '@src/utils/findNodeHandle';
4850
import KeyboardUtils from '@src/utils/keyboard';
4951
import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu';
5052
import getCursorPosition from './ReportActionCompose/getCursorPosition';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// eslint-disable-next-line no-restricted-imports
2+
import {findNodeHandle} from 'react-native';
3+
4+
/** Don't add new `findNodeHandle` usages, this is only a temporary solution. We're going to remove the function in the future */
5+
export default findNodeHandle;

src/utils/findNodeHandle/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type {Component, ComponentClass} from 'react';
2+
import type {NodeHandle} from 'react-native/Libraries/ReactNative/RendererProxy';
3+
4+
/** Don't add new `findNodeHandle` usages, this is only a temporary solution. We're going to remove the function in the future */
5+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
6+
function findNodeHandle(componentOrHandle: null | number | Component<any, any> | ComponentClass<any>): null | NodeHandle {
7+
// eslint-disable-next-line no-console
8+
console.warn('findNodeHandle is not supported on web. Use the ref property of the component instead.');
9+
return null;
10+
}
11+
12+
export default findNodeHandle;

0 commit comments

Comments
 (0)