diff --git a/Libraries/Components/View/TestFabricView.js b/Libraries/Components/View/TestFabricView.js deleted file mode 100644 index 01e0e4897..000000000 --- a/Libraries/Components/View/TestFabricView.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @providesModule TestFabricView - * @flow - * @format - */ -'use strict'; - -/** - * This is a switch on the correct View to use for Fabric testing purposes - */ -let TestFabricView; -const FabricTestModule = require('NativeModules').FabricTestModule; -if (FabricTestModule && FabricTestModule.IS_FABRIC_ENABLED) { - TestFabricView = require('FabricView'); -} else { - TestFabricView = require('View'); -} - -module.exports = TestFabricView; diff --git a/Libraries/Components/View/requireFabricView.js b/Libraries/Components/View/requireFabricView.js new file mode 100644 index 000000000..55a7c40f4 --- /dev/null +++ b/Libraries/Components/View/requireFabricView.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @providesModule requireFabricView + * @flow + * @format + */ +'use strict'; + +/** + * This is a switch on the correct view to use for Fabric + */ +module.exports = (name: string, fabric: boolean) => { + switch (name) { + case 'View': + return fabric ? require('FabricView') : require('View'); + case 'Text': + return fabric ? require('FabricText') : require('Text'); + default: + throw new Error(name + ' is not supported by Fabric yet'); + } +}; diff --git a/Libraries/ReactNative/AppRegistry.js b/Libraries/ReactNative/AppRegistry.js index 21fdca68a..8ddfb6411 100644 --- a/Libraries/ReactNative/AppRegistry.js +++ b/Libraries/ReactNative/AppRegistry.js @@ -35,7 +35,6 @@ export type AppConfig = { component?: ComponentProvider, run?: Function, section?: boolean, - fabric?: boolean, }; export type Runnable = { component?: ComponentProvider, @@ -85,7 +84,6 @@ const AppRegistry = { appConfig.appKey, appConfig.component, appConfig.section, - appConfig.fabric, ); } }); @@ -100,13 +98,12 @@ const AppRegistry = { appKey: string, componentProvider: ComponentProvider, section?: boolean, - fabric?: boolean, ): string { runnables[appKey] = { componentProvider, run: appParameters => { let renderFunc = renderApplication; - if (fabric) { + if (appParameters.fabric) { invariant( fabricRendererProvider != null, 'A Fabric renderer provider must be set to render Fabric components', diff --git a/Libraries/ReactNative/renderFabricSurface.js b/Libraries/ReactNative/renderFabricSurface.js index 0279f1759..46536a755 100644 --- a/Libraries/ReactNative/renderFabricSurface.js +++ b/Libraries/ReactNative/renderFabricSurface.js @@ -34,7 +34,7 @@ function renderFabricSurface( fabric={true} rootTag={rootTag} WrapperComponent={WrapperComponent}> - + ); diff --git a/Libraries/Text/TestFabricText.js b/Libraries/Text/TestFabricText.js deleted file mode 100644 index cdedcc317..000000000 --- a/Libraries/Text/TestFabricText.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @providesModule TestFabricText - * @flow - * @format - */ -'use strict'; - -/** - * This is a switch on the correct Text to use for Fabric testing purposes - */ -let TestFabricText; -const FabricTestModule = require('NativeModules').FabricTestModule; -if (FabricTestModule && FabricTestModule.IS_FABRIC_ENABLED) { - TestFabricText = require('FabricText'); -} else { - TestFabricText = require('Text'); -} - -module.exports = TestFabricText; diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstrumentationTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstrumentationTest.java index 754439515..3f0a7e250 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstrumentationTest.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstrumentationTest.java @@ -13,7 +13,6 @@ import android.view.View; import android.view.ViewGroup; import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.ReactContext; -import com.facebook.react.testing.fabric.FabricTestModule; import com.facebook.react.testing.idledetection.IdleWaiter; /** @@ -116,11 +115,7 @@ public abstract class ReactInstrumentationTest extends * Override this method to provide extra native modules to be loaded before the app starts */ protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { - ReactInstanceSpecForTest instanceSpec = new ReactInstanceSpecForTest(); - if (isFabricTest()) { - instanceSpec.addNativeModule(new FabricTestModule(isFabricTest())); - } - return instanceSpec; + return new ReactInstanceSpecForTest(); } /** diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/fabric/FabricTestModule.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/fabric/FabricTestModule.java deleted file mode 100644 index 0e4fe05b0..000000000 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/fabric/FabricTestModule.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.testing.fabric; - -import com.facebook.react.common.MapBuilder; -import java.util.Map; -import javax.annotation.Nullable; - -import com.facebook.react.bridge.BaseJavaModule; -import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.bridge.ReadableMap; - -/** - * Module to indicate if a test is using Fabric - */ -public final class FabricTestModule extends BaseJavaModule { - - private final boolean mIsFabricEnabled; - - public FabricTestModule(boolean isFabricEnabled) { - mIsFabricEnabled = isFabricEnabled; - } - - @Override - public String getName() { - return "FabricTestModule"; - } - - @Override - public Map getConstants() { - return MapBuilder.of("IS_FABRIC_ENABLED", mIsFabricEnabled); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 5d4a88bc5..5b8e3c539 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -490,6 +490,9 @@ public class ReactRootView extends SizeMonitoringFrameLayout if (appProperties != null) { appParams.putMap("initialProps", Arguments.fromBundle(appProperties)); } + if (isFabric()) { + appParams.putBoolean("fabric", true); + } mShouldLogContentAppeared = true;