`addUIBlock` not working in New Architecture.

This issue has been tracked since 2022-09-22.

Description

When I enable fabric and turbomodule, addUIBlock seems not working because the callback will never be called:

UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
        uiManager.addUIBlock(new UIBlock() {
            @Override
            public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
                HMapView hMapView;
                try {
                    hMapView = (HMapView) nativeViewHierarchyManager.resolveView(viewTag);
                } catch (Exception e) {
                    QLog.e(e);
                    hMapView = null;
                }
                if(hMapView != null){
                    WritableNativeMap map = hMapView.getLocationParams();
                    callback.invoke(map);
                }
            }
        });

If I understand the new architecture right, uiManager is not get used when fabric is enabled, but the JSIModule. But I didn't find functions which act the same with addUIBlock.

So what is the solution when I want to use addUIBlock when fabric is on?

Version

0.68.1

Output of npx react-native info

System:
OS: macOS 11.6.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 139.06 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.19.3 - ~/.nvm/versions/node/v14.19.3/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.17 - ~/.nvm/versions/node/v14.19.3/bin/npm
Watchman: 2022.01.17.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
Android SDK:
Android NDK: 21.1.6352462
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8609683
Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: Not Found
react-native: 0.68.1 => 0.68.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
info React Native v0.70.1 is now available (your project is running on v0.68.1).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.70.1.
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.68.1.
info To upgrade, run "react-native upgrade".

Steps to reproduce

None.

Snack, code example, screenshot, or link to a repository

UIManagerModule uiManager = context.getNativeModule(UIManagerModule.class);
        uiManager.addUIBlock(new UIBlock() {
            @Override
            public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
                Log.i(TAG, "it works");
            }
        });

when fabric is on.

More Details About Repo
Owner Name facebook
Repo Name react-native
Full Name facebook/react-native
Language JavaScript
Created Date 2015-01-09
Updated Date 2022-10-03
Star Count 105144
Watcher Count 3666
Fork Count 22469
Issue Count 2232

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date