Skip to content

Commit de3fddd

Browse files
authored
Merge pull request #61776 from nabi-ebrahimi/fix/report-debug-console-errors
Fix React key and ref console errors in Report Debug Page
2 parents 00e3be9 + 0734f43 commit de3fddd

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

src/components/SidePanel/HelpModal/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function Help({sidePanelTranslateX, closeSidePanel, shouldHideSidePanelBackdrop}
2121
const styles = useThemeStyles();
2222
const {isExtraLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
2323
const {paddingTop, paddingBottom} = useSafeAreaPaddings();
24+
2425
const [isRHPVisible = false] = useOnyx(ONYXKEYS.MODAL, {selector: (modal) => modal?.type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED, canBeMissing: true});
2526
const uniqueModalId = useMemo(() => ComposerFocusManager.getId(), []);
2627

src/pages/Debug/ConstantSelector.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {useRoute} from '@react-navigation/native';
2-
import React, {useEffect} from 'react';
2+
import type {ForwardedRef} from 'react';
3+
import React, {forwardRef, useEffect} from 'react';
4+
import type {View} from 'react-native';
35
import type {ValueOf} from 'type-fest';
46
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
57
import Navigation from '@libs/Navigation/Navigation';
@@ -29,7 +31,12 @@ type ConstantSelectorProps = {
2931
policyID?: string;
3032
};
3133

32-
function ConstantSelector({formType, policyID, errorText = '', name, value, onInputChange}: ConstantSelectorProps) {
34+
function ConstantSelector(
35+
{formType, policyID, errorText = '', name, value, onInputChange}: ConstantSelectorProps,
36+
// The ref is required by React.forwardRef to avoid warnings, even though it's not used yet.
37+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
38+
ref: ForwardedRef<View>,
39+
) {
3340
const fieldValue = (useRoute().params as Record<string, string> | undefined)?.[name];
3441

3542
useEffect(() => {
@@ -64,4 +71,4 @@ function ConstantSelector({formType, policyID, errorText = '', name, value, onIn
6471

6572
ConstantSelector.displayName = 'ConstantSelector';
6673

67-
export default ConstantSelector;
74+
export default forwardRef(ConstantSelector);

src/pages/Debug/DateTimeSelector.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {useRoute} from '@react-navigation/native';
2-
import React, {useEffect} from 'react';
2+
import type {ForwardedRef} from 'react';
3+
import React, {forwardRef, useEffect} from 'react';
4+
import type {View} from 'react-native';
35
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
46
import Navigation from '@libs/Navigation/Navigation';
57
import CONST from '@src/CONST';
@@ -23,7 +25,12 @@ type DateTimeSelectorProps = {
2325
inputID: string;
2426
};
2527

26-
function DateTimeSelector({errorText = '', name, value, onInputChange}: DateTimeSelectorProps) {
28+
function DateTimeSelector(
29+
{errorText = '', name, value, onInputChange}: DateTimeSelectorProps,
30+
// The ref is required by React.forwardRef to avoid warnings, even though it's not used yet.
31+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
32+
ref: ForwardedRef<View>,
33+
) {
2734
const fieldValue = (useRoute().params as Record<string, string> | undefined)?.[name];
2835

2936
useEffect(() => {
@@ -58,4 +65,4 @@ function DateTimeSelector({errorText = '', name, value, onInputChange}: DateTime
5865

5966
DateTimeSelector.displayName = 'DateTimeSelector';
6067

61-
export default DateTimeSelector;
68+
export default forwardRef(DateTimeSelector);

src/pages/Debug/DebugDetails.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type DebugDetailsProps = {
5555
function DebugDetails({formType, data, policyHasEnabledTags, policyID, children, onSave, onDelete, validate}: DebugDetailsProps) {
5656
const {translate} = useLocalize();
5757
const styles = useThemeStyles();
58-
const [formDraftData] = useOnyx(ONYXKEYS.FORMS.DEBUG_DETAILS_FORM_DRAFT);
58+
const [formDraftData] = useOnyx(ONYXKEYS.FORMS.DEBUG_DETAILS_FORM_DRAFT, {canBeMissing: true});
5959
const booleanFields = useMemo(
6060
() =>
6161
Object.entries(data ?? {})
@@ -167,6 +167,7 @@ function DebugDetails({formType, data, policyHasEnabledTags, policyID, children,
167167
const numberOfLines = DebugUtils.getNumberOfLinesFromString((formDraftData?.[key as keyof typeof formDraftData] as string) ?? value);
168168
return (
169169
<InputWrapper
170+
key={key}
170171
InputComponent={TextInput}
171172
inputID={key}
172173
accessibilityLabel={key}
@@ -187,6 +188,7 @@ function DebugDetails({formType, data, policyHasEnabledTags, policyID, children,
187188
<View style={[styles.mb5, styles.ph5, styles.gap5]}>
188189
{numberFields.map(([key, value]) => (
189190
<InputWrapper
191+
key={key}
190192
InputComponent={TextInput}
191193
inputID={key}
192194
accessibilityLabel={key}
@@ -234,6 +236,7 @@ function DebugDetails({formType, data, policyHasEnabledTags, policyID, children,
234236
<View style={[styles.mb5, styles.ph5, styles.gap5]}>
235237
{booleanFields.map(([key, value]) => (
236238
<InputWrapper
239+
key={key}
237240
InputComponent={CheckboxWithLabel}
238241
label={key}
239242
inputID={key}

src/pages/Debug/Report/DebugReportPage.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ function DebugReportPage({
131131
>
132132
<View style={[styles.mb5, styles.ph5, styles.gap5]}>
133133
{metadata?.map(({title, subtitle, message, action}) => (
134-
<View style={[StyleUtils.getBackgroundColorStyle(theme.cardBG), styles.p5, styles.br4, styles.flexColumn, styles.gap2]}>
134+
<View
135+
key={title}
136+
style={[StyleUtils.getBackgroundColorStyle(theme.cardBG), styles.p5, styles.br4, styles.flexColumn, styles.gap2]}
137+
>
135138
<View style={[styles.flexRow, styles.justifyContentBetween]}>
136139
<Text style={styles.h4}>{title}</Text>
137140
<Text>{subtitle}</Text>

0 commit comments

Comments
 (0)