React-Native 应用程序在导航时崩溃 [英] React-Native App getting crashed on navigate

查看:71
本文介绍了React-Native 应用程序在导航时崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

After upgrading React-Native App to below configuration

"react": "16.9.0",反应原生":0.61.5",反应导航":^ 4.0.10",反应导航堆栈":^ 1.10.3",反应导航抽屉":^ 2.3.3","react-redux": "^7.1.3","redux": "^4.0.4","redux-promise": "^0.6.0","redux-saga": "^1.1.3"

"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"

使用 createStackNavigator 页面中的this.props.navigation.navigate()"重定向时,应用程序崩溃.但是当我从 createDrawerNavigator 重定向到同一页面时,它可以工作.在升级之前,这工作正常.

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)

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

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

非常感谢任何帮助.

推荐答案

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

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

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"

这篇关于React-Native 应用程序在导航时崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆