From 29a76918a988d4120dda5597575bf5be477a7635 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Fri, 15 May 2026 06:36:46 -0700 Subject: [PATCH] Deprecate legacy UIBlock and addUIBlock/prependUIBlock APIs Summary: Deprecate `UIBlock`, `NativeViewHierarchyManager`, and the `addUIBlock`/`prependUIBlock` methods on `UIManagerModule`. These are legacy Paper architecture APIs that are already non-functional stubs. Libraries should migrate to `UIManagerListener` or View Commands. The Fabric replacement for `UIBlock` already exists at `com.facebook.react.fabric.interop.UIBlock` and uses `UIBlockViewResolver` instead of `NativeViewHierarchyManager`. Changelog: [Android][Deprecated] - Deprecate `UIBlock` interface and `UIManagerModule.addUIBlock`/`prependUIBlock` methods. Use `UIManagerListener` or View Commands instead. Reviewed By: javache Differential Revision: D104995161 fbshipit-source-id: 447067129765761a587a8fc5a1b57710b29a1132 --- .../java/com/facebook/react/uimanager/UIBlock.kt | 8 +++++++- .../facebook/react/uimanager/UIManagerModule.java | 13 ++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIBlock.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIBlock.kt index 8e099c30abc..b1eabaa0bf6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIBlock.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIBlock.kt @@ -7,7 +7,13 @@ package com.facebook.react.uimanager -/** A task to execute on the UI View for third party libraries. */ +/** + * A task to execute on the UI View for third party libraries. + * + * @deprecated This interface is part of the Legacy Architecture and will be removed in a future + * release. Use [com.facebook.react.bridge.UIManagerListener] or View Commands instead. + */ +@Deprecated("Use UIManagerListener or View Commands instead") public fun interface UIBlock { public fun execute( @Suppress("DEPRECATION") nativeViewHierarchyManager: NativeViewHierarchyManager diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index f3f2ef87d9f..fc5fe32dfe3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -568,12 +568,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule * after all currently queued view updates have completed. * * @param block that contains UI logic you want to execute. - *

Usage Example: - *

UIManagerModule uiManager = reactContext.getNativeModule(UIManagerModule.class); - * uiManager.addUIBlock(new UIBlock() { public void execute (NativeViewHierarchyManager nvhm) - * { View view = nvhm.resolveView(tag); // ...execute your code on View (e.g. snapshot the - * view) } }); + * @deprecated This method is a no-op stub retained for backward compatibility. Use {@link + * UIManagerListener} or View Commands instead. */ + @Deprecated + @SuppressWarnings("deprecation") public void addUIBlock(UIBlock block) {} /** @@ -581,7 +580,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule * before all currently queued view updates have completed. * * @param block that contains UI logic you want to execute. + * @deprecated This method is a no-op stub retained for backward compatibility. Use {@link + * UIManagerListener} or View Commands instead. */ + @Deprecated + @SuppressWarnings("deprecation") public void prependUIBlock(UIBlock block) {} @Override