fixing error Warning: TypeError: _reactNative.BackHandler.removeEventListener is not a function (it is undefined) #3793
+8
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.