Skip to content

Commit cbb7c7c

Browse files
ayc1facebook-github-bot
authored andcommitted
Pass fabric flag from native to JS
Reviewed By: mdvacca Differential Revision: D7373722 fbshipit-source-id: 3cd051f38677900693f3da797effa11f9161df37
1 parent 046d4ce commit cbb7c7c

File tree

8 files changed

+31
-98
lines changed

8 files changed

+31
-98
lines changed

Libraries/Components/View/TestFabricView.js

-24
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @providesModule requireFabricView
8+
* @flow
9+
* @format
10+
*/
11+
'use strict';
12+
13+
/**
14+
* This is a switch on the correct view to use for Fabric
15+
*/
16+
module.exports = (name: string, fabric: boolean) => {
17+
switch (name) {
18+
case 'View':
19+
return fabric ? require('FabricView') : require('View');
20+
case 'Text':
21+
return fabric ? require('FabricText') : require('Text');
22+
default:
23+
throw new Error(name + ' is not supported by Fabric yet');
24+
}
25+
};

Libraries/ReactNative/AppRegistry.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export type AppConfig = {
3535
component?: ComponentProvider,
3636
run?: Function,
3737
section?: boolean,
38-
fabric?: boolean,
3938
};
4039
export type Runnable = {
4140
component?: ComponentProvider,
@@ -85,7 +84,6 @@ const AppRegistry = {
8584
appConfig.appKey,
8685
appConfig.component,
8786
appConfig.section,
88-
appConfig.fabric,
8987
);
9088
}
9189
});
@@ -100,13 +98,12 @@ const AppRegistry = {
10098
appKey: string,
10199
componentProvider: ComponentProvider,
102100
section?: boolean,
103-
fabric?: boolean,
104101
): string {
105102
runnables[appKey] = {
106103
componentProvider,
107104
run: appParameters => {
108105
let renderFunc = renderApplication;
109-
if (fabric) {
106+
if (appParameters.fabric) {
110107
invariant(
111108
fabricRendererProvider != null,
112109
'A Fabric renderer provider must be set to render Fabric components',

Libraries/ReactNative/renderFabricSurface.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function renderFabricSurface<Props: Object>(
3434
fabric={true}
3535
rootTag={rootTag}
3636
WrapperComponent={WrapperComponent}>
37-
<RootComponent {...initialProps} rootTag={rootTag} />
37+
<RootComponent {...initialProps} rootTag={rootTag} fabric={true} />
3838
</AppContainer>
3939
);
4040

Libraries/Text/TestFabricText.js

-24
This file was deleted.

ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstrumentationTest.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import android.view.ViewGroup;
1414
import com.facebook.react.bridge.JavaScriptModule;
1515
import com.facebook.react.bridge.ReactContext;
16-
import com.facebook.react.testing.fabric.FabricTestModule;
1716
import com.facebook.react.testing.idledetection.IdleWaiter;
1817

1918
/**
@@ -116,11 +115,7 @@ protected <T extends JavaScriptModule> T getJSModule(Class<T> jsInterface) {
116115
* Override this method to provide extra native modules to be loaded before the app starts
117116
*/
118117
protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
119-
ReactInstanceSpecForTest instanceSpec = new ReactInstanceSpecForTest();
120-
if (isFabricTest()) {
121-
instanceSpec.addNativeModule(new FabricTestModule(isFabricTest()));
122-
}
123-
return instanceSpec;
118+
return new ReactInstanceSpecForTest();
124119
}
125120

126121
/**

ReactAndroid/src/androidTest/java/com/facebook/react/testing/fabric/FabricTestModule.java

-39
This file was deleted.

ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java

+3
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ private void defaultJSEntryPoint() {
490490
if (appProperties != null) {
491491
appParams.putMap("initialProps", Arguments.fromBundle(appProperties));
492492
}
493+
if (isFabric()) {
494+
appParams.putBoolean("fabric", true);
495+
}
493496

494497
mShouldLogContentAppeared = true;
495498

0 commit comments

Comments
 (0)