colorfy-software / react-native-modalfy

🥞 Modal citizen of React Native.
https://colorfy-software.gitbook.io/react-native-modalfy
MIT License
1.16k stars 48 forks source link

[Android] Cannot read property 'addListener' of undefined #131

Closed ermamud closed 8 months ago

ermamud commented 1 year ago

Hi, I am React Native with Expo (v0.72.5) and after installing this package using the expo command, I am getting an error only on Android. I created the same IntroModal you have in the examples and this is the error:

TypeError: Cannot read property 'addListener' of undefined
TypeError: Cannot read property 'addListener' of undefined
    at MegaAlert (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:146229:33)
    at renderWithHooks (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:90173:33)
    at mountIndeterminateComponent (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:93255:34)
    at beginWork (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:94501:49)
    at beginWork$1 (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:98850:29)
    at performUnitOfWork (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:98192:29)
    at workLoopSync (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:98127:28)
    at renderRootSync (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:98104:25)
    at performSyncWorkOnRoot (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:97829:40)
    at flushSyncCallbacks (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:87021:36)
    at flushSyncCallbacksOnlyInLegacyMode (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:87003:29)
    at scheduleUpdateOnFiber (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:97390:47)
    at dispatchSetState (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:91150:34)
    at ?anon_0_ (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:130308:26)
    at next (native)
    at asyncGeneratorStep (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:6080:26)
    at _next (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:6099:29)
    at tryCallOne (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/Release/554c6x4t/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/root/react-native/packages/react-native/ReactAndroid/hermes-engine/.cxx/Release/554c6x4t/arm64-v8a/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:39583:26)
    at _callTimer (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:39462:17)
    at _callReactNativeMicrotasksPass (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:39507:17)
    at callReactNativeMicrotasks (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:39713:44)
    at __callReactNativeMicrotasks (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:3691:46)
    at anonymous (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:3465:45)
    at __guard (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:3664:15)
    at flushedQueue (http://10.0.2.2:8081/node_modules/expo/AppEntry.bundle//&platform=android&dev=true&minify=false&app=com.account.app&modulesOnly=false&runModule=true:3464:21)

any idea how can I get this issue fixed?

Thank you, Ernesto

CharlesMangwa commented 1 year ago

hi @ermamud! could you add a repro on snack please? this would help a lot, thx!

ermamud commented 1 year ago

I am not able to reproduce the same exact issue using a snack, after further testing, I am getting the previous error on both iOS and Android but only after I did a native build, previously it was just working fine.

I created this snack and you can see that is not working, not sure if it's the same error because I don't see any error, the web version works fine but the ios/android is freezing after trying to open the modal:

https://snack.expo.dev/@ermamud/modalfy_error_test

thanks

CharlesMangwa commented 8 months ago

hey @ermamud, sorry for the long delay. i hope you managed to sort this out, but just in case, here's your snack fixed. you can focus on ./components/introModal.tsx: https://snack.expo.dev/trVMWWgcMpHkd6jpBYZKW.

tldr;: the way you were updating animatedValue + the use of View instead of Animated.View is what was causing the "crash".