[React Native] Inline calls to FabricUIManager in shared code (#15490)
* [React Native] Inline calls to FabricUIManager in shared code * Call global.nativeFabricUIManager directly as short term fix * Add flow types * Add nativeFabricUIManager global to eslint config * Adding eslint global to bundle validation script
Eli White committed
Apr 29, 2019 at 14:31 UTC
12e5a13cf2ea48ad7f527e68caf5faf8bf724c97
6 files changed
+37
-6
.eslintrc.js
+6
@@ -125,6 +125,12 @@ module.exports = {
125
// https://github.com/jest-community/eslint-plugin-jest
126
'jest/no-focused-tests': ERROR,
127
}
128
+ },
129
+ {
130
+ files: ['packages/react-native-renderer/**/*.js'],
131
+ globals: {
132
+ nativeFabricUIManager: true,
133
+ }
134
}
135
],
136
packages/react-native-renderer/src/NativeMethodsMixin.js
+8
-3
@@ -18,7 +18,6 @@ import type {
18
import invariant from 'shared/invariant';
19
// Modules provided by RN:
20
import TextInputState from 'TextInputState';
21
-import * as FabricUIManager from 'FabricUIManager';
21
import UIManager from 'UIManager';
22
23
import {create} from './ReactNativeAttributePayload';
@@ -86,7 +85,10 @@ export default function(
85
}
86
87
if (maybeInstance.canonical) {
89
- FabricUIManager.measure(
88
+ // We can't call FabricUIManager here because it won't be loaded in paper
89
+ // at initialization time. See https://github.com/facebook/react/pull/15490
90
+ // for more info.
91
+ nativeFabricUIManager.measure(
92
maybeInstance.node,
93
mountSafeCallback_NOT_REALLY_SAFE(this, callback),
94
);
@@ -131,7 +133,10 @@ export default function(
133
}
134
135
if (maybeInstance.canonical) {
134
- FabricUIManager.measureInWindow(
136
+ // We can't call FabricUIManager here because it won't be loaded in paper
137
+ // at initialization time. See https://github.com/facebook/react/pull/15490
138
+ // for more info.
139
+ nativeFabricUIManager.measureInWindow(
140
maybeInstance.node,
141
mountSafeCallback_NOT_REALLY_SAFE(this, callback),
142
);
packages/react-native-renderer/src/ReactNativeComponent.js
+8
-3
@@ -19,7 +19,6 @@ import type {
19
import React from 'react';
20
// Modules provided by RN:
21
import TextInputState from 'TextInputState';
22
-import * as FabricUIManager from 'FabricUIManager';
22
import UIManager from 'UIManager';
23
24
import {create} from './ReactNativeAttributePayload';
@@ -101,7 +100,10 @@ export default function(
100
}
101
102
if (maybeInstance.canonical) {
104
- FabricUIManager.measure(
103
+ // We can't call FabricUIManager here because it won't be loaded in paper
104
+ // at initialization time. See https://github.com/facebook/react/pull/15490
105
+ // for more info.
106
+ nativeFabricUIManager.measure(
107
maybeInstance.node,
108
mountSafeCallback_NOT_REALLY_SAFE(this, callback),
109
);
@@ -144,7 +146,10 @@ export default function(
146
}
147
148
if (maybeInstance.canonical) {
147
- FabricUIManager.measureInWindow(
149
+ // We can't call FabricUIManager here because it won't be loaded in paper
150
+ // at initialization time. See https://github.com/facebook/react/pull/15490
151
+ // for more info.
152
+ nativeFabricUIManager.measureInWindow(
153
maybeInstance.node,
154
mountSafeCallback_NOT_REALLY_SAFE(this, callback),
155
);
packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js
+5
@@ -48,6 +48,11 @@ describe('ReactFabric', () => {
48
NativeMethodsMixin =
49
ReactFabric.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
50
.NativeMethodsMixin;
51
+
52
+ global.nativeFabricUIManager = {
53
+ measure: FabricUIManager.measure,
54
+ measureInWindow: FabricUIManager.measureInWindow,
55
+ };
56
});
57
58
it('should be able to create and render a native component', () => {
scripts/flow/react-native-host-hooks.js
+7
@@ -144,6 +144,13 @@ declare module 'FabricUIManager' {
144
): void;
145
}
146
147
+// This is needed for a short term solution.
148
+// See https://github.com/facebook/react/pull/15490 for more info
149
+declare var nativeFabricUIManager: {
150
+ measure(node: Node, callback: MeasureOnSuccessCallback): void,
151
+ measureInWindow(node: Node, callback: MeasureInWindowOnSuccessCallback): void,
152
+};
153
+
154
declare module 'View' {
155
declare module.exports: typeof React$Component;
156
}
scripts/rollup/validate/eslintrc.rn.js
+3
@@ -18,6 +18,9 @@ module.exports = {
18
__REACT_DEVTOOLS_GLOBAL_HOOK__: true,
19
// FB
20
__DEV__: true,
21
+ // Fabric. See https://github.com/facebook/react/pull/15490
22
+ // for more information
23
+ nativeFabricUIManager: true,
24
},
25
parserOptions: {
26
ecmaVersion: 5,