Skip to content

fixing error Warning: TypeError: _reactNative.BackHandler.removeEventListener is not a function (it is undefined) #3793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

simonecorsato
Copy link

@simonecorsato simonecorsato commented Aug 20, 2025

Description

The change has been done to fix the error: "Warning: TypeError: _reactNative.BackHandler.removeEventListener is not a function (it is undefined)" that is happening using react native version 0.77.2.

Added also a new commit to avoid the error "Attempt to invoke virtual method 'void com.facebook.react.uimanager.UlManagerModule.onBatchComplete()' on a null object reference"
In the commit I 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).

Changelog

The 1st change is in the file react-native-ui-lib/lib/components/Keyboard/KeyboardInput/KeyboardAccessoryView.tsx and is related to the BackHandler.removeEventListener that should now be handled in a different way with new version of react native.
The 2nd change is in the file react-native-ui-lib/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java and is the guard to avoid the null pointer exception

Please note that for the 2nd issue, as stated in #3594, also the uilib-native dependency should be patched to completely solve the problem.

…Listener 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)
…anager.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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant