反应原生应用程序在导航时崩溃



将 React-Native App 升级到以下配置后

<小时 />
"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 在从 createStackNavigator 页面使用 "this.props.navigation.navigate((" 重定向时崩溃。但是当我从createDrawerNavigator重定向到同一页面时,它可以工作。 在升级之前,这工作正常。

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)

但是当我从createDrawerNavigator重定向到同一页面时,它可以工作。

任何帮助真的非常感谢。

这是react-navigation": "^4.0.10的问题

verion 4.0仅适用于Android 9及以上版本,我们必须降级版本3

通过降级版本,问题已修复。这对我有用

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

相关内容

  • 没有找到相关文章

最新更新