react-native-modal icon indicating copy to clipboard operation
react-native-modal copied to clipboard

When i press back button getting this issue: TypeError: Cannot read properties of null (reading 'remove')

Open harish92 opened this issue 3 years ago • 8 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-modal/dist/modal.js b/node_modules/react-native-modal/dist/modal.js
index 80f4e75..c6db3c5 100644
--- a/node_modules/react-native-modal/dist/modal.js
+++ b/node_modules/react-native-modal/dist/modal.js
@@ -458,7 +458,8 @@ export class ReactNativeModal extends React.Component {
     componentWillUnmount() {
         BackHandler.removeEventListener('hardwareBackPress', this.onBackButtonPress);
         if (this.didUpdateDimensionsEmitter) {
-            this.didUpdateDimensionsEmitter.remove();
+            DeviceEventEmitter.removeAllListeners('didUpdateDimensions')
+            // this.didUpdateDimensionsEmitter.remove();
         }
         if (this.interactionHandle) {
             InteractionManager.clearInteractionHandle(this.interactionHandle);

This issue body was partially generated by patch-package.

harish92 avatar Jan 06 '23 07:01 harish92

@harish92 getting this error on pressing back button ERROR TypeError: Cannot read property 'remove' of undefined

code as added below componentWillUnmount() { BackHandler.removeEventListener('hardwareBackPress', this.onBackButtonPress); DeviceEventEmitter.removeListener.remove('didUpdateDimensions', this.handleDimensionsUpdate); if (this.interactionHandle) { InteractionManager.clearInteractionHandle(this.interactionHandle); this.interactionHandle = null; } }

using this version of "react-native-modal": "^12.0.2",

note:- also tried with DeviceEventEmitter.removeAllListeners.remove('didUpdateDimensions', this.handleDimensionsUpdate); getting error --** ERROR TypeError: undefined is not a function** and DeviceEventEmitter.removeAllListeners('didUpdateDimensions', this.handleDimensionsUpdate); in this case state got empty values and remaining pages also have same issue even no API call making.

98rahul avatar Jan 30 '23 10:01 98rahul

hi guys! is there any updates about this? I'm also facing the same issue with a react native expo project with a managed workflow, it crashes the app on build.

I see this warning when running from expo start. Screen Shot 2023-02-06 at 5 42 35 PM

jarapamikaella avatar Feb 07 '23 01:02 jarapamikaella

Facing same issue :/ any update?

camhammel avatar Feb 19 '23 01:02 camhammel

Same issue after upgrading to React Native 0.72

lukebrandonfarrell avatar Oct 19 '23 10:10 lukebrandonfarrell

Facing issue after upgrading to React Native 0.73.2

gkasireddy202 avatar Apr 09 '24 19:04 gkasireddy202