5/5 Hook up Bridgeless' UIManager.hasViewManagerConfig with Fabric's native component registry
Summary: Allow JS to detect if a native UI component is registered to `RCTComponentViewFactory.mm` with JS `UIManager.hasViewManagerConfig(componentName)`. Fyi, `UIManager.js` is - `DummyUIManager.js` for Bridgeless, - `LazyUIManager.js` for Fabric with SVC enabled, - and `PaperUIManager.js`. for Fabric with SVC disabled. # How it works in Bridgeless - `DummyUIManager.hasViewManagerConfig()` checks whether a component exists in the binary. It is hooked up to `unstable_hasComponent()`, - which is hooked up to the native function `RCTInstallNativeComponentRegistryBinding()`, - which returns whether a component has been registered to `RCTComponentViewFactory` - (and also registers the native component if hasn't been registered yet). Changelog: [Bridgeless][JS] Hook up Venice's UIManager.hasViewManagerConfig with Fabric's native component registry Reviewed By: RSNara Differential Revision: D33511659 fbshipit-source-id: 14519378ce3e4247516fcf5a6f83a82aa87c7919
This commit is contained in:
Родитель
a620d7dc85
Коммит
b3a34194c0
|
@ -11,11 +11,13 @@
|
|||
'use strict';
|
||||
|
||||
import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes';
|
||||
import {unstable_hasComponent} from 'react-native/Libraries/NativeComponent/NativeComponentRegistryUnstable';
|
||||
|
||||
module.exports = {
|
||||
getViewManagerConfig: (viewManagerName: string): mixed => {
|
||||
console.warn(
|
||||
'Attempting to get config for view manager: ' + viewManagerName,
|
||||
'getViewManagerConfig is unavailable in Bridgeless, use hasViewManagerConfig instead. viewManagerName: ' +
|
||||
viewManagerName,
|
||||
);
|
||||
if (viewManagerName === 'RCTVirtualText') {
|
||||
return {};
|
||||
|
@ -23,10 +25,15 @@ module.exports = {
|
|||
return null;
|
||||
},
|
||||
hasViewManagerConfig: (viewManagerName: string): boolean => {
|
||||
return (
|
||||
viewManagerName === 'RCTVirtualText' ||
|
||||
viewManagerName === 'RCTShimmeringView'
|
||||
);
|
||||
const staticViewConfigsEnabled = global.__fbStaticViewConfig === true;
|
||||
if (staticViewConfigsEnabled) {
|
||||
return unstable_hasComponent(viewManagerName);
|
||||
} else {
|
||||
return (
|
||||
viewManagerName === 'RCTVirtualText' ||
|
||||
viewManagerName === 'RCTShimmeringView'
|
||||
);
|
||||
}
|
||||
},
|
||||
getConstants: (): {...} => ({}),
|
||||
getConstantsForViewManager: (viewManagerName: string) => {},
|
||||
|
|
Загрузка…
Ссылка в новой задаче