Skip to content

Commit daff0c9

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Disallow usage of "NativeProps" symbol in internal components (#51889)
Summary: Pull Request resolved: #51889 Changelog: [Internal] Reviewed By: huntie Differential Revision: D76244543 fbshipit-source-id: 0ccbc29f99e3fac992b8f0040e16a73f72350969
1 parent b649791 commit daff0c9

18 files changed

Lines changed: 110 additions & 78 deletions

packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export type ReturnKeyType =
6363

6464
export type SubmitBehavior = 'submit' | 'blurAndSubmit' | 'newline';
6565

66-
export type NativeProps = $ReadOnly<{
66+
export type AndroidTextInputNativeProps = $ReadOnly<{
6767
// This allows us to inherit everything from ViewProps except for style (see below)
6868
// This must be commented for Fabric codegen to work.
6969
...Omit<ViewProps, 'style'>,
@@ -606,7 +606,7 @@ export type NativeProps = $ReadOnly<{
606606
text?: ?string,
607607
}>;
608608

609-
type NativeType = HostComponent<NativeProps>;
609+
type NativeType = HostComponent<AndroidTextInputNativeProps>;
610610

611611
type NativeCommands = TextInputNativeCommands<NativeType>;
612612

@@ -725,10 +725,11 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
725725
},
726726
};
727727

728-
let AndroidTextInputNativeComponent = NativeComponentRegistry.get<NativeProps>(
729-
'AndroidTextInput',
730-
() => __INTERNAL_VIEW_CONFIG,
731-
);
728+
let AndroidTextInputNativeComponent =
729+
NativeComponentRegistry.get<AndroidTextInputNativeProps>(
730+
'AndroidTextInput',
731+
() => __INTERNAL_VIEW_CONFIG,
732+
);
732733

733734
// flowlint-next-line unclear-type:off
734-
export default ((AndroidTextInputNativeComponent: any): HostComponent<NativeProps>);
735+
export default ((AndroidTextInputNativeComponent: any): HostComponent<AndroidTextInputNativeProps>);

packages/react-native/Libraries/Image/TextInlineImageNativeComponent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {ImageResizeMode} from './ImageResizeMode';
1818

1919
import * as NativeComponentRegistry from '../NativeComponent/NativeComponentRegistry';
2020

21-
type NativeProps = $ReadOnly<{
21+
type RCTTextInlineImageNativeProps = $ReadOnly<{
2222
...ViewProps,
2323
resizeMode?: ?ImageResizeMode,
2424
src?: ?$ReadOnlyArray<?$ReadOnly<{uri?: ?string, ...}>>,
@@ -40,8 +40,8 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
4040
},
4141
};
4242

43-
const TextInlineImage: HostComponent<NativeProps> =
44-
NativeComponentRegistry.get<NativeProps>(
43+
const TextInlineImage: HostComponent<RCTTextInlineImageNativeProps> =
44+
NativeComponentRegistry.get<RCTTextInlineImageNativeProps>(
4545
'RCTTextInlineImage',
4646
() => __INTERNAL_VIEW_CONFIG,
4747
);

packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,7 +2436,7 @@ export type ReturnKeyType =
24362436
| \\"route\\"
24372437
| \\"yahoo\\";
24382438
export type SubmitBehavior = \\"submit\\" | \\"blurAndSubmit\\" | \\"newline\\";
2439-
export type NativeProps = $ReadOnly<{
2439+
export type AndroidTextInputNativeProps = $ReadOnly<{
24402440
...Omit<ViewProps, \\"style\\">,
24412441
autoComplete?: WithDefault<
24422442
| \\"birthdate-day\\"
@@ -2594,11 +2594,11 @@ export type NativeProps = $ReadOnly<{
25942594
mostRecentEventCount: Int32,
25952595
text?: ?string,
25962596
}>;
2597-
type NativeType = HostComponent<NativeProps>;
2597+
type NativeType = HostComponent<AndroidTextInputNativeProps>;
25982598
type NativeCommands = TextInputNativeCommands<NativeType>;
25992599
declare export const Commands: NativeCommands;
26002600
declare export const __INTERNAL_VIEW_CONFIG: PartialViewConfig;
2601-
declare export default HostComponent<NativeProps>;
2601+
declare export default HostComponent<AndroidTextInputNativeProps>;
26022602
"
26032603
`;
26042604

@@ -4616,15 +4616,15 @@ declare module.exports: typeof RelativeImageStub;
46164616
`;
46174617

46184618
exports[`public API should not change unintentionally Libraries/Image/TextInlineImageNativeComponent.js 1`] = `
4619-
"type NativeProps = $ReadOnly<{
4619+
"type RCTTextInlineImageNativeProps = $ReadOnly<{
46204620
...ViewProps,
46214621
resizeMode?: ?ImageResizeMode,
46224622
src?: ?$ReadOnlyArray<?$ReadOnly<{ uri?: ?string, ... }>>,
46234623
tintColor?: ?ColorValue,
46244624
headers?: ?{ [string]: string },
46254625
}>;
46264626
declare export const __INTERNAL_VIEW_CONFIG: PartialViewConfig;
4627-
declare const TextInlineImage: HostComponent<NativeProps>;
4627+
declare const TextInlineImage: HostComponent<RCTTextInlineImageNativeProps>;
46284628
declare export default typeof TextInlineImage;
46294629
"
46304630
`;

packages/react-native/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {HostComponent} from '../../types/HostComponent';
1515

1616
import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent';
1717

18-
type NativeProps = $ReadOnly<{
18+
type RCTActivityIndicatorViewNativeProps = $ReadOnly<{
1919
...ViewProps,
2020

2121
/**
@@ -48,6 +48,9 @@ type NativeProps = $ReadOnly<{
4848
size?: WithDefault<'small' | 'large', 'small'>,
4949
}>;
5050

51-
export default (codegenNativeComponent<NativeProps>('ActivityIndicatorView', {
52-
paperComponentName: 'RCTActivityIndicatorView',
53-
}): HostComponent<NativeProps>);
51+
export default (codegenNativeComponent<RCTActivityIndicatorViewNativeProps>(
52+
'ActivityIndicatorView',
53+
{
54+
paperComponentName: 'RCTActivityIndicatorView',
55+
},
56+
): HostComponent<RCTActivityIndicatorViewNativeProps>);

packages/react-native/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type DrawerSlideEvent = $ReadOnly<{
3030
offset: Float,
3131
}>;
3232

33-
type NativeProps = $ReadOnly<{
33+
type AndroidDrawerLayoutNativeProps = $ReadOnly<{
3434
...ViewProps,
3535
/**
3636
* Determines whether the keyboard gets dismissed in response to a drag.
@@ -108,7 +108,7 @@ type NativeProps = $ReadOnly<{
108108
statusBarBackgroundColor?: ?ColorValue,
109109
}>;
110110

111-
type NativeType = HostComponent<NativeProps>;
111+
type NativeType = HostComponent<AndroidDrawerLayoutNativeProps>;
112112

113113
interface NativeCommands {
114114
+openDrawer: (viewRef: React.ElementRef<NativeType>) => void;
@@ -119,6 +119,6 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
119119
supportedCommands: ['openDrawer', 'closeDrawer'],
120120
});
121121

122-
export default (codegenNativeComponent<NativeProps>(
122+
export default (codegenNativeComponent<AndroidDrawerLayoutNativeProps>(
123123
'AndroidDrawerLayout',
124124
): NativeType);

packages/react-native/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import type {HostComponent} from '../../types/HostComponent';
1313

1414
import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent';
1515

16-
type NativeProps = $ReadOnly<{
16+
type AndroidHorizontalScrollContentViewNativeProps = $ReadOnly<{
1717
...ViewProps,
1818

1919
removeClippedSubviews?: ?boolean,
2020
}>;
2121

22-
type NativeType = HostComponent<NativeProps>;
22+
type NativeType = HostComponent<AndroidHorizontalScrollContentViewNativeProps>;
2323

24-
export default (codegenNativeComponent<NativeProps>(
24+
export default (codegenNativeComponent<AndroidHorizontalScrollContentViewNativeProps>(
2525
'AndroidHorizontalScrollContentView',
2626
{interfaceOnly: true},
2727
): NativeType);

packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNative
2121
import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent';
2222
import * as React from 'react';
2323

24-
type NativeProps = $ReadOnly<{
24+
type AndroidSwipeRefreshLayoutNativeProps = $ReadOnly<{
2525
...ViewProps,
2626

2727
/**
@@ -56,7 +56,7 @@ type NativeProps = $ReadOnly<{
5656
refreshing: boolean,
5757
}>;
5858

59-
type NativeType = HostComponent<NativeProps>;
59+
type NativeType = HostComponent<AndroidSwipeRefreshLayoutNativeProps>;
6060

6161
interface NativeCommands {
6262
+setNativeRefreshing: (
@@ -69,6 +69,6 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
6969
supportedCommands: ['setNativeRefreshing'],
7070
});
7171

72-
export default (codegenNativeComponent<NativeProps>(
72+
export default (codegenNativeComponent<AndroidSwipeRefreshLayoutNativeProps>(
7373
'AndroidSwipeRefreshLayout',
7474
): NativeType);

packages/react-native/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNative
2121
import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent';
2222
import * as React from 'react';
2323

24-
type SwitchChangeEvent = $ReadOnly<{
24+
type AndroidSwitchChangeEvent = $ReadOnly<{
2525
value: boolean,
2626
target: Int32,
2727
}>;
2828

29-
type NativeProps = $ReadOnly<{
29+
type AndroidSwitchNativeProps = $ReadOnly<{
3030
...ViewProps,
3131

3232
// Props
@@ -41,10 +41,10 @@ type NativeProps = $ReadOnly<{
4141
trackTintColor?: ?ColorValue,
4242

4343
// Events
44-
onChange?: BubblingEventHandler<SwitchChangeEvent>,
44+
onChange?: BubblingEventHandler<AndroidSwitchChangeEvent>,
4545
}>;
4646

47-
type NativeType = HostComponent<NativeProps>;
47+
type NativeType = HostComponent<AndroidSwitchNativeProps>;
4848

4949
interface NativeCommands {
5050
+setNativeValue: (
@@ -57,6 +57,9 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
5757
supportedCommands: ['setNativeValue'],
5858
});
5959

60-
export default (codegenNativeComponent<NativeProps>('AndroidSwitch', {
61-
interfaceOnly: true,
62-
}): NativeType);
60+
export default (codegenNativeComponent<AndroidSwitchNativeProps>(
61+
'AndroidSwitch',
62+
{
63+
interfaceOnly: true,
64+
},
65+
): NativeType);

packages/react-native/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ import codegenNativeCommands from '../../../../Libraries/Utilities/codegenNative
1616
import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent';
1717
import * as React from 'react';
1818

19-
type NativeProps = $ReadOnly<{
19+
type DebuggingOverlayNativeProps = $ReadOnly<{
2020
...ViewProps,
2121
}>;
22-
export type DebuggingOverlayNativeComponentType = HostComponent<NativeProps>;
22+
export type DebuggingOverlayNativeComponentType =
23+
HostComponent<DebuggingOverlayNativeProps>;
2324

2425
export type TraceUpdate = {
2526
id: number,
@@ -56,6 +57,6 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
5657
],
5758
});
5859

59-
export default (codegenNativeComponent<NativeProps>(
60+
export default (codegenNativeComponent<DebuggingOverlayNativeProps>(
6061
'DebuggingOverlay',
61-
): HostComponent<NativeProps>);
62+
): HostComponent<DebuggingOverlayNativeProps>);

packages/react-native/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type {HostComponent} from '../../types/HostComponent';
1818

1919
import codegenNativeComponent from '../../../../Libraries/Utilities/codegenNativeComponent';
2020

21-
type NativeProps = $ReadOnly<{
21+
type AndroidProgressBarNativeProps = $ReadOnly<{
2222
...ViewProps,
2323

2424
//Props
@@ -31,6 +31,9 @@ type NativeProps = $ReadOnly<{
3131
testID?: WithDefault<string, ''>,
3232
}>;
3333

34-
export default (codegenNativeComponent<NativeProps>('AndroidProgressBar', {
35-
interfaceOnly: true,
36-
}): HostComponent<NativeProps>);
34+
export default (codegenNativeComponent<AndroidProgressBarNativeProps>(
35+
'AndroidProgressBar',
36+
{
37+
interfaceOnly: true,
38+
},
39+
): HostComponent<AndroidProgressBarNativeProps>);

0 commit comments

Comments
 (0)