From 971f7712be1641552fca66c4ff078ca2e7da3675 Mon Sep 17 00:00:00 2001 From: Simone Corsato Date: Wed, 20 Aug 2025 14:44:38 +0200 Subject: [PATCH 1/2] fixing error Warning: TypeError: _reactNative.BackHandler.removeEventListener is not a function (it is undefined) This error is located at: in KeyboardAccessoryView (created by Editor) in RNCSafeAreaView in Unknown (created by Editor) in Editor (created by inject-with-app-context-editorPanel-reportStoryPanel(Editor)) in inject-with-app-context-editorPanel-reportStoryPanel(Editor) (created by StoreWrapper) in MobXProvider (created by StoreWrapper) --- .../Keyboard/KeyboardInput/KeyboardAccessoryView.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.tsx b/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.tsx index 00051ef3e9..4881e3a953 100644 --- a/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.tsx +++ b/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.tsx @@ -62,6 +62,7 @@ export type KeyboardAccessoryViewProps = kbTrackingViewProps & { * @gif: https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/KeyboardAccessoryView/KeyboardAccessoryView.gif?raw=true */ class KeyboardAccessoryView extends Component { + androidBackHandlerSubscription?: { remove: () => void }; static scrollBehaviors = KeyboardTrackingView.scrollBehaviors; static defaultProps = { @@ -94,8 +95,8 @@ class KeyboardAccessoryView extends Component { if (this.customInputControllerEventsSubscriber) { this.customInputControllerEventsSubscriber.remove(); } - if (IsAndroid) { - BackHandler.removeEventListener('hardwareBackPress', this.onAndroidBackPressed); + if (IsAndroid && this.androidBackHandlerSubscription) { + this.androidBackHandlerSubscription.remove(); } } @@ -146,7 +147,7 @@ class KeyboardAccessoryView extends Component { registerAndroidBackHandler() { if (IsAndroid) { - BackHandler.addEventListener('hardwareBackPress', this.onAndroidBackPressed); + this.androidBackHandlerSubscription = BackHandler.addEventListener('hardwareBackPress', this.onAndroidBackPressed); } } From 9d081b8c8a04f8fbc49ee6015a92c7e0f0aa28b0 Mon Sep 17 00:00:00 2001 From: Simone Corsato Date: Wed, 20 Aug 2025 15:20:26 +0200 Subject: [PATCH 2/2] fixing "Attempt to invoke virtual method 'void com.facebook.react.uimanager.UlManagerModule.onBatchComplete()' on a null object reference" Added a guard to avoid null pointer exception. There is no replacement for onBatchComplete in TurboModules/Fabric. The correct approach is to let React Native handle UI batching, and only call onBatchComplete if UIManagerModule is available (legacy mode). Your current guarded code is the best practice for compatibility. --- .../reactnativeuilib/keyboardinput/utils/RuntimeUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java b/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java index 95c5e8ea47..d71210b137 100644 --- a/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +++ b/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java @@ -9,7 +9,10 @@ public class RuntimeUtils { private static final Runnable sUIUpdateClosure = new Runnable() { @Override public void run() { - ReactContextHolder.getContext().getNativeModule(UIManagerModule.class).onBatchComplete(); + UIManagerModule uiManager = ReactContextHolder.getContext().getNativeModule(UIManagerModule.class); + if (uiManager != null) { + uiManager.onBatchComplete(); + } } };