Closed okcompewter closed 2 years ago
I can easily reproduce this with a simple button that calls closeAllModals()
. When there are no modals open, the app crashes with the first error above.
I found a workaround so far by using currentModal && closeAllModals()
, that seems to prevent this crash (it only calls closeAllModals
if there is some currentModal
that exists).
Hey @okcompewter! Thanks for reporting this, will work on a patch with these fixes. Will keep you posted.
Thanks so much! Really appreciate your work :)
OK turns out the fix for the crash was easier than I thought, will be in next release!
Woohoo! Thanks for the optional chaining fix. Give me a holler when the release is out :)
🚀 v3.2.0
is out with the fix (and a few of other nice things 😁)!
I've updated to 3.2.0, and it seems to have fixed a lot of errors, but I'm still seeing this one crash log in production occasionally:
Are you sure the recent optional chaining fix doesn't need done elsewhere as well?
When looking at your fix, before the slice check:
currentModalHash: [...currentState.stack.openedItems].slice(-1)[0]?.hash,
may it be possible that any of these are also undefined: currentState
or currentState.stack
or currentState.stack.openedItems
?
The crash:
Fatal Exception: com.facebook.react.common.c: TypeError: undefined is not an object (evaluating 'f.default.getState().currentModal')
This error is located at:
in l
in p
in RCTView
in Unknown
in R
in Unknown
in RCTView
in Unknown
in R
in Unknown
in p
in y
in P
in RCTView
in Unknown
in l
in RCTView
in Unknown
in R
in Unknown
in PanGestureHandler
in S
in w
in RCTView
in Unknown
in v
in l
in C
in x
in p
in RCTView
in Unknown
in M
in b
in C
in l
in v
in Unknown
in Unknown
in Unknown
in Unknown
in B
in Unknown
in RCTView
in Unknown
in RCTView
in Unknown
in b, stack:
C:\Users\...\node_modules\react-native-modalfy\src\lib\ModalProvider.tsx:39:openModal
C:\Users\...\app\screens\raid-screen\raid-screen.tsx:29:useEffect$argument_0
C:\Users\...\node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-prod.js:5467:commitHookEffectListMount
C:\Users\...\node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-prod.js:7003:flushPassiveEffects
C:\Users\...\node_modules\react-native\Libraries\Renderer\implementations\ReactNativeRenderer-prod.js:6849:scheduleCallback$argument_1
C:\Users\...\node_modules\scheduler\cjs\scheduler.production.min.js:16:V
C:\Users\...\node_modules\scheduler\cjs\scheduler.production.min.js:10:w
C:\Users\...\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:214:_allocateCallback$argument_0
C:\Users\...\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:112:_callTimer
C:\Users\...\node_modules\react-native\Libraries\Core\Timers\JSTimers.js:357:callTimers
C:\Users\...\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:419:__callFunction
C:\Users\...\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:116:__guard$argument_0
C:\Users\...\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:370:__guard
C:\Users\...\node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:115:callFunctionReturnFlushedQueue
value@-1
at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:83)
at java.lang.reflect.Method.invoke(Method.java)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
at java.lang.Thread.run(Thread.java:920)
Created new Issue 78.
Thanks for your great library!
I am currently on v3.0.1, and getting a lot of crash reports dealing with "undefined is not an object".
Can this fail more gracefully (just early return) when undefined is not an object?
closeAllModals()
openModal()