React-Native App getting crashed on navigate

£可爱£侵袭症+ 提交于 2021-02-10 14:21:06

问题


After upgrading React-Native App to below configuration


"react": "16.9.0", "react-native": "0.61.5", "react-navigation": "^4.0.10", "react-navigation-stack": "^1.10.3", "react-navigation-drawer": "^2.3.3", "react-redux": "^7.1.3", "redux": "^4.0.4", "redux-promise": "^0.6.0", "redux-saga": "^1.1.3"


App getting crashed when redirecting using "this.props.navigation.navigate()" from createStackNavigator page. But when I redirect from createDrawerNavigator to the same page it works. Before upgrading this was working fine.

TypeError: Cannot read property 'state' of undefined

This error is located at:
    in Navigator (at createKeyboardAwareNavigator.js:12)
    in KeyboardAwareNavigator (at SceneView.js:9)
    in SceneView (at StackViewLayout.tsx:889)
    in RCTView (at StackViewLayout.tsx:888)
    in RCTView (at StackViewLayout.tsx:887)
    in RCTView (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewCard.tsx:106)
    in RCTView (at createAnimatedComponent.js:151)
    in AnimatedComponent (at screens.native.js:71)
    in Screen (at StackViewCard.tsx:93)
    in Card (at createPointerEventsContainer.tsx:95)
    in Container (at StackViewLayout.tsx:975)
    in RCTView (at screens.native.js:101)
    in ScreenContainer (at StackViewLayout.tsx:384)
    in RCTView (at createAnimatedComponent.js:151)
    in AnimatedComponent (at StackViewLayout.tsx:374)
    in PanGestureHandler (at StackViewLayout.tsx:367)
    in StackViewLayout (at withOrientation.js:30)
    in withOrientation (at StackView.tsx:104)
    in RCTView (at Transitioner.tsx:267)
    in Transitioner (at StackView.tsx:41)
    in StackView (at createNavigator.js:80)
    in Navigator (at createKeyboardAwareNavigator.js:12)
    in KeyboardAwareNavigator (at SceneView.js:9)
    in SceneView (at SwitchView.js:12)
    in SwitchView (at createNavigator.js:80)
    in Navigator (at createAppContainer.js:430)
    in NavigationContainer (at App.js:42)
    in Provider (at App.js:41)
    in RCTView (at Root.js:14)
    in Root (at connectStyle.js:392)
    in Styled(Root) (at App.js:40)
    in App (at renderApplication.js:40)
    in RCTView (at AppContainer.js:101)
    in RCTView (at AppContainer.js:119)
    in AppContainer (at renderApplication.js:39)
reportException @ ExceptionsManager.js:44
handleException @ ExceptionsManager.js:113
showErrorDialog @ ReactFiberErrorDialog.js:45
showErrorDialog @ ReactNativeRenderer-dev.js:16635
logCapturedError @ ReactNativeRenderer-dev.js:16641
logError @ ReactNativeRenderer-dev.js:16747
callback @ ReactNativeRenderer-dev.js:18042
callCallback @ ReactNativeRenderer-dev.js:7595
commitUpdateEffects @ ReactNativeRenderer-dev.js:7639
commitUpdateQueue @ ReactNativeRenderer-dev.js:7630
commitLifeCycles @ ReactNativeRenderer-dev.js:17115
commitLayoutEffects @ ReactNativeRenderer-dev.js:20002
invokeGuardedCallbackImpl @ ReactNativeRenderer-dev.js:307
invokeGuardedCallback @ ReactNativeRenderer-dev.js:531
commitRootImpl @ ReactNativeRenderer-dev.js:19767
unstable_runWithPriority @ scheduler.development.js:643
runWithPriority @ ReactNativeRenderer-dev.js:5591
commitRoot @ ReactNativeRenderer-dev.js:19589
runRootCallback @ ReactNativeRenderer-dev.js:18709
(anonymous) @ ReactNativeRenderer-dev.js:5642
unstable_runWithPriority @ scheduler.development.js:643
runWithPriority @ ReactNativeRenderer-dev.js:5591
flushSyncCallbackQueueImpl @ ReactNativeRenderer-dev.js:5638
flushSyncCallbackQueue @ ReactNativeRenderer-dev.js:5627
scheduleUpdateOnFiber @ ReactNativeRenderer-dev.js:18556
enqueueSetState @ ReactNativeRenderer-dev.js:7799
Component.setState @ react.development.js:325
Transitioner._this.handleTransitionEnd @ Transitioner.js:1
_callTimer @ JSTimers.js:148
callTimers @ JSTimers.js:399
__callFunction @ MessageQueue.js:436
(anonymous) @ MessageQueue.js:111
__guard @ MessageQueue.js:384
callFunctionReturnFlushedQueue @ MessageQueue.js:110
(anonymous) @ debuggerWorker.js:69
Show 5 more frames
ExceptionsManager.js:44 TypeError: Cannot read property 'state' of undefined

This error is located at:
    in NavigationContainer (at App.js:42)
    in Provider (at App.js:41)
    in RCTView (at Root.js:14)
    in Root (at connectStyle.js:392)
    in Styled(Root) (at App.js:40)
    in App (at renderApplication.js:40)
    in RCTView (at AppContainer.js:101)
    in RCTView (at AppContainer.js:119)
    in AppContainer (at renderApplication.js:39)
reportException @ ExceptionsManager.js:44
handleException @ ExceptionsManager.js:113
showErrorDialog @ ReactFiberErrorDialog.js:45
showErrorDialog @ ReactNativeRenderer-dev.js:16635
logCapturedError @ ReactNativeRenderer-dev.js:16641
logError @ ReactNativeRenderer-dev.js:16747
update.callback @ ReactNativeRenderer-dev.js:18010
callCallback @ ReactNativeRenderer-dev.js:7595
commitUpdateEffects @ ReactNativeRenderer-dev.js:7639
commitUpdateQueue @ ReactNativeRenderer-dev.js:7627
commitLifeCycles @ ReactNativeRenderer-dev.js:17138
commitLayoutEffects @ ReactNativeRenderer-dev.js:20002
invokeGuardedCallbackImpl @ ReactNativeRenderer-dev.js:307
invokeGuardedCallback @ ReactNativeRenderer-dev.js:531
commitRootImpl @ ReactNativeRenderer-dev.js:19767
unstable_runWithPriority @ scheduler.development.js:643
runWithPriority @ ReactNativeRenderer-dev.js:5591
commitRoot @ ReactNativeRenderer-dev.js:19589
runRootCallback @ ReactNativeRenderer-dev.js:18709
(anonymous) @ ReactNativeRenderer-dev.js:5642
unstable_runWithPriority @ scheduler.development.js:643
runWithPriority @ ReactNativeRenderer-dev.js:5591
flushSyncCallbackQueueImpl @ ReactNativeRenderer-dev.js:5638
flushSyncCallbackQueue @ ReactNativeRenderer-dev.js:5627
scheduleUpdateOnFiber @ ReactNativeRenderer-dev.js:18556
enqueueSetState @ ReactNativeRenderer-dev.js:7799
Component.setState @ react.development.js:325
Transitioner._this.handleTransitionEnd @ Transitioner.js:1
_callTimer @ JSTimers.js:148
callTimers @ JSTimers.js:399
__callFunction @ MessageQueue.js:436
(anonymous) @ MessageQueue.js:111
__guard @ MessageQueue.js:384
callFunctionReturnFlushedQueue @ MessageQueue.js:110
(anonymous) @ debuggerWorker.js:69
Show 5 more frames
ExceptionsManager.js:44 TypeError: Cannot read property 'state' of undefined

This error is located at:
    in NavigationContainer (at App.js:42)
    in Provider (at App.js:41)
    in RCTView (at Root.js:14)
    in Root (at connectStyle.js:392)
    in Styled(Root) (at App.js:40)
    in App (at renderApplication.js:40)
    in RCTView (at AppContainer.js:101)
    in RCTView (at AppContainer.js:119)
    in AppContainer (at renderApplication.js:39)

But when I redirect from createDrawerNavigator to the same page it works.

Any help is really appreciated.


回答1:


This is issue of react-navigation": "^4.0.10

verion 4.0 only works in Android 9 onwards for below version we has to downgrade version 3

By Downgrading version, issue is fixed. This is working for me

"react": "^16.12.0",
"react-native": "^0.61.5"
"react-native-gesture-handler": "^1.5.3",
"react-navigation": "3.11.0"


来源:https://stackoverflow.com/questions/59078949/react-native-app-getting-crashed-on-navigate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!