Skip to content

Commit b3a3419

Browse files
p-sunfacebook-github-bot
authored andcommitted
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
1 parent a620d7d commit b3a3419

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Libraries/ReactNative/DummyUIManager.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,29 @@
1111
'use strict';
1212

1313
import type {RootTag} from 'react-native/Libraries/Types/RootTagTypes';
14+
import {unstable_hasComponent} from 'react-native/Libraries/NativeComponent/NativeComponentRegistryUnstable';
1415

1516
module.exports = {
1617
getViewManagerConfig: (viewManagerName: string): mixed => {
1718
console.warn(
18-
'Attempting to get config for view manager: ' + viewManagerName,
19+
'getViewManagerConfig is unavailable in Bridgeless, use hasViewManagerConfig instead. viewManagerName: ' +
20+
viewManagerName,
1921
);
2022
if (viewManagerName === 'RCTVirtualText') {
2123
return {};
2224
}
2325
return null;
2426
},
2527
hasViewManagerConfig: (viewManagerName: string): boolean => {
26-
return (
27-
viewManagerName === 'RCTVirtualText' ||
28-
viewManagerName === 'RCTShimmeringView'
29-
);
28+
const staticViewConfigsEnabled = global.__fbStaticViewConfig === true;
29+
if (staticViewConfigsEnabled) {
30+
return unstable_hasComponent(viewManagerName);
31+
} else {
32+
return (
33+
viewManagerName === 'RCTVirtualText' ||
34+
viewManagerName === 'RCTShimmeringView'
35+
);
36+
}
3037
},
3138
getConstants: (): {...} => ({}),
3239
getConstantsForViewManager: (viewManagerName: string) => {},

0 commit comments

Comments
 (0)