[flow] Eliminate a few React.Element type that will be synced to react-native (#30719)
## Summary Flow will eventually remove the specific `React.Element` type. For most of the code, it can be replaced with `React.MixedElement` or `React.Node`. When specific react elements are required, it needs to be replaced with either `React$Element` which will trigger a `internal-type` lint error that can be disabled project-wide, or use `ExactReactElement_DEPRECATED`. Fortunately in this case, this one can be replaced with just `React.MixedElement`. ## How did you test this change? `flow`
Sam Zhou committed
Aug 16, 2024 at 12:53 UTC
85fb95cdffdd95f2f908ee71974cae06b1c866e1
3 files changed
+11
-5
packages/react-native-renderer/src/ReactNativeRenderer.js
+2
-2
@@ -8,7 +8,7 @@
8
*/
9
10
import type {ReactPortal, ReactNodeList} from 'shared/ReactTypes';
11
-import type {ElementRef, Element, ElementType} from 'react';
11
+import type {ElementRef, ElementType, MixedElement} from 'react';
12
import type {FiberRoot} from 'react-reconciler/src/ReactInternalTypes';
13
import type {RenderRootOptions} from './ReactNativeTypes';
14
@@ -117,7 +117,7 @@ function nativeOnCaughtError(
117
}
118
119
function render(
120
- element: Element<ElementType>,
120
+ element: MixedElement,
121
containerTag: number,
122
callback: ?() => void,
123
options: ?RenderRootOptions,
packages/react-native-renderer/src/ReactNativeTypes.js
+8
-3
@@ -9,7 +9,12 @@
9
* @flow strict
10
*/
11
12
-import type {ElementRef, ElementType, Element, AbstractComponent} from 'react';
12
+import type {
13
+ ElementRef,
14
+ ElementType,
15
+ MixedElement,
16
+ AbstractComponent,
17
+} from 'react';
18
19
export type MeasureOnSuccessCallback = (
20
x: number,
@@ -221,7 +226,7 @@ export type ReactNativeType = {
226
eventType: string,
227
): void,
228
render(
224
- element: Element<ElementType>,
229
+ element: MixedElement,
230
containerTag: number,
231
callback: ?() => void,
232
options: ?RenderRootOptions,
@@ -256,7 +261,7 @@ export type ReactFabricType = {
261
eventType: string,
262
): void,
263
render(
259
- element: Element<ElementType>,
264
+ element: MixedElement,
265
containerTag: number,
266
callback: ?() => void,
267
concurrentRoot: ?boolean,
packages/react/index.js
+1
@@ -15,6 +15,7 @@ export type AbstractComponent<
15
> = React$AbstractComponent<Config, Instance>;
16
export type ElementType = React$ElementType;
17
export type Element<+C> = React$Element<C>;
18
+export type MixedElement = React$Element<ElementType>;
19
export type Key = React$Key;
20
export type Ref<C> = React$Ref<C>;
21
export type Node = React$Node;