From 9daae5a5f2b988e1b481e3cdc3eef3ecf2d8f474 Mon Sep 17 00:00:00 2001 From: Paige Sun Date: Fri, 7 Jan 2022 16:14:43 -0800 Subject: [PATCH] For Fabric with StaticViewConfigs, fix UIManager to use LazyUImanager, not PaperUIManager Summary: Changelog: [JS] For Fabric with StaticViewConfigs, fix UIManager to use LazyUImanager, not PaperUIManager Reviewed By: fkgozali Differential Revision: D33459937 fbshipit-source-id: 4298be7e1e455856cbcf3162b100099cd8c9ce09 --- Libraries/ReactNative/UIManager.js | 19 +++++++++++-------- Libraries/ReactNative/UIManagerInjection.js | 8 +++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Libraries/ReactNative/UIManager.js b/Libraries/ReactNative/UIManager.js index 020fd639682e4d..97bed6f78b9a74 100644 --- a/Libraries/ReactNative/UIManager.js +++ b/Libraries/ReactNative/UIManager.js @@ -8,11 +8,10 @@ * @format */ -import UIManagerInjection from './UIManagerInjection'; import type {Spec} from './NativeUIManager'; import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes'; -interface UIManagerJSInterface extends Spec { +export interface UIManagerJSInterface extends Spec { +getViewManagerConfig: (viewManagerName: string) => Object; +hasViewManagerConfig: (viewManagerName: string) => boolean; +createView: ( @@ -32,11 +31,15 @@ interface UIManagerJSInterface extends Spec { ) => void; } -const UIManager: UIManagerJSInterface = - global.RN$Bridgeless === true - ? require('./DummyUIManager') // No UIManager in bridgeless mode - : UIManagerInjection.unstable_UIManager == null - ? require('./PaperUIManager') - : UIManagerInjection.unstable_UIManager; +var UIManager: UIManagerJSInterface; +if (global.RN$Bridgeless === true) { + // $FlowExpectedError[incompatible-type] + UIManager = require('./DummyUIManager'); +} else { + const {unstable_UIManager} = require('./UIManagerInjection'); + UIManager = unstable_UIManager + ? unstable_UIManager + : require('./PaperUIManager'); +} module.exports = UIManager; diff --git a/Libraries/ReactNative/UIManagerInjection.js b/Libraries/ReactNative/UIManagerInjection.js index 97648a6424f46e..289598fec0078d 100644 --- a/Libraries/ReactNative/UIManagerInjection.js +++ b/Libraries/ReactNative/UIManagerInjection.js @@ -8,6 +8,8 @@ * @format */ -export default { - unstable_UIManager: (null: ?any), -}; +import type {UIManagerJSInterface} from './UIManager'; + +const unstable_UIManager: ?UIManagerJSInterface = null; + +export {unstable_UIManager};