Skip to content

Commit b8c2c7a

Browse files
committed
Fix React Native flow types
1 parent 2e8bbcb commit b8c2c7a

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

scripts/error-codes/codes.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -374,5 +374,8 @@
374374
"383": "This query has received fewer parameters than the last time the same query was used. Always pass the exact number of parameters that the query needs.",
375375
"384": "Refreshing the cache is not supported in Server Components.",
376376
"385": "A mutable source was mutated while the %s component was rendering. This is not supported. Move any mutations into event handlers or effects.",
377-
"386": "The current renderer does not support microtasks. This error is likely caused by a bug in React. Please file an issue."
377+
"386": "The current renderer does not support microtasks. This error is likely caused by a bug in React. Please file an issue.",
378+
"387": "Event cannot be both direct and bubbling: %s",
379+
"388": "View config getter callback for component `%s` must be a function (received `%s`)",
380+
"389": "View config getter callback for component `%s` must be a function (received `%s`).%s"
378381
}

scripts/rollup/shims/react-native/ReactNativeViewConfigRegistry.js

+5-13
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,10 @@
88
* @flow strict-local
99
*/
1010

11-
/* eslint-disable react-internal/invariant-args */
12-
1311
'use strict';
1412

15-
import type {
16-
ReactNativeBaseComponentViewConfig,
17-
ViewConfigGetter,
18-
} from './ReactNativeTypes';
19-
20-
const invariant = require('invariant');
13+
import {type ViewConfig} from './ReactNativeTypes';
14+
import invariant from 'invariant';
2115

2216
// Event configs
2317
const customBubblingEventTypes: {
@@ -42,9 +36,7 @@ exports.customDirectEventTypes = customDirectEventTypes;
4236
const viewConfigCallbacks = new Map();
4337
const viewConfigs = new Map();
4438

45-
function processEventTypes(
46-
viewConfig: ReactNativeBaseComponentViewConfig<>,
47-
): void {
39+
function processEventTypes(viewConfig: ViewConfig): void {
4840
const {bubblingEventTypes, directEventTypes} = viewConfig;
4941

5042
if (__DEV__) {
@@ -82,7 +74,7 @@ function processEventTypes(
8274
* A callback is provided to load the view config from UIManager.
8375
* The callback is deferred until the view is actually rendered.
8476
*/
85-
exports.register = function(name: string, callback: ViewConfigGetter): string {
77+
exports.register = function(name: string, callback: () => ViewConfig): string {
8678
invariant(
8779
!viewConfigCallbacks.has(name),
8880
'Tried to register two views with the same name %s',
@@ -103,7 +95,7 @@ exports.register = function(name: string, callback: ViewConfigGetter): string {
10395
* If this is the first time the view has been used,
10496
* This configuration will be lazy-loaded from UIManager.
10597
*/
106-
exports.get = function(name: string): ReactNativeBaseComponentViewConfig<> {
98+
exports.get = function(name: string): ViewConfig {
10799
let viewConfig;
108100
if (!viewConfigs.has(name)) {
109101
const callback = viewConfigCallbacks.get(name);

scripts/rollup/shims/react-native/createReactNativeComponentClass.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
'use strict';
1212

1313
import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';
14-
15-
import type {ViewConfigGetter} from './ReactNativeTypes';
14+
import {type ViewConfig} from './ReactNativeTypes';
1615

1716
const {register} = ReactNativeViewConfigRegistry;
1817

@@ -26,7 +25,7 @@ const {register} = ReactNativeViewConfigRegistry;
2625
*/
2726
const createReactNativeComponentClass = function(
2827
name: string,
29-
callback: ViewConfigGetter,
28+
callback: () => ViewConfig,
3029
): string {
3130
return register(name, callback);
3231
};

0 commit comments

Comments
 (0)