Skip to content

Commit 36a9b7e

Browse files
SamChou19815meta-codesync[bot]
authored andcommitted
Replace React.ElementProps in tests and examples (facebook#54035)
Summary: Pull Request resolved: facebook#54035 `React.ElementConfig` is often the better choice. See https://flow.org/en/docs/react/types/#toc-react-elementprops Changelog: [Internal] Reviewed By: panagosg7 Differential Revision: D83749631 fbshipit-source-id: 81b21c1a0dced5bc578d3a5752c303b57b467f7b
1 parent 041b4c3 commit 36a9b7e

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

packages/react-native/jest/mockComponent.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ export default function mockComponent<
3737
: // $FlowFixMe[incompatible-type]
3838
jest.requireActual<TComponentModule>(moduleName);
3939

40-
const SuperClass: typeof React.Component<
41-
React.ElementProps<typeof RealComponent>,
42-
> =
40+
const SuperClass: typeof React.Component<{...}> =
4341
typeof RealComponent === 'function' &&
4442
RealComponent.prototype.constructor instanceof React.Component
4543
? RealComponent

packages/rn-tester/js/examples/FlatList/FlatList-BaseOnViewableItemsChanged.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
'use strict';
1212

13-
import type {ViewToken} from 'react-native/Libraries/Lists/ViewabilityHelper';
13+
import type {
14+
ViewabilityConfig,
15+
ViewToken,
16+
} from 'react-native/Libraries/Lists/ViewabilityHelper';
1417

1518
import BaseFlatListExample from './BaseFlatListExample';
1619
import * as React from 'react';
1720
import {useCallback, useRef, useState} from 'react';
18-
import {FlatList, StyleSheet, View} from 'react-native';
19-
20-
type FlatListProps = React.ElementProps<typeof FlatList>;
21-
type ViewabilityConfig = FlatListProps['viewabilityConfig'];
21+
import {StyleSheet, View} from 'react-native';
2222

2323
const BASE_VIEWABILITY_CONFIG = {
2424
minimumViewTime: 1000,

packages/rn-tester/js/examples/SectionList/SectionList-BaseOnViewableItemsChanged.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
* @format
99
*/
1010

11-
import type {ViewToken} from 'react-native/Libraries/Lists/ViewabilityHelper';
11+
import type {
12+
ViewabilityConfig,
13+
ViewToken,
14+
} from 'react-native/Libraries/Lists/ViewabilityHelper';
1215

1316
import SectionListBaseExample from './SectionListBaseExample';
1417
import * as React from 'react';
1518
import {useRef, useState} from 'react';
16-
import {SectionList, StyleSheet, View} from 'react-native';
17-
18-
type SectionListProps = React.ElementProps<typeof SectionList>;
19-
type ViewabilityConfig = SectionListProps['viewabilityConfig'];
19+
import {StyleSheet, View} from 'react-native';
2020

2121
const BASE_VIEWABILITY_CONFIG = {
2222
minimumViewTime: 1000,

packages/rn-tester/js/examples/TextInput/ExampleTextInput.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,9 @@ import {RNTesterThemeContext} from '../../components/RNTesterTheme';
1212
import React, {useContext} from 'react';
1313
import {StyleSheet, TextInput} from 'react-native';
1414

15-
type LooseOmit<O: interface {}, K: $Keys<$FlowFixMe>> = Pick<
16-
O,
17-
Exclude<$Keys<O>, K>,
18-
>;
19-
2015
const ExampleTextInput: component(
2116
ref?: React.RefSetter<null | React.ElementRef<typeof TextInput>>,
22-
...props: LooseOmit<React.ElementProps<typeof TextInput>, 'ref'>
17+
...props: Omit<React.ElementConfig<typeof TextInput>, 'ref'>
2318
) = ({
2419
ref,
2520
...props

0 commit comments

Comments
 (0)