繁体   English   中英

React Native:使用pop()或goBack()时出现性能问题,导致无限循环。 但是使用`reset`就可以了

[英]React Native: Performance issue when using `pop()` or `goBack()`, causing an infinite loop. But using `reset` is fine

我在我的应用程序中遇到一个奇怪的问题,调用goBack()pop()会使该应用程序占用我的所有RAM并变得无法使用,并显示无限循环的症状。 当我查看RAM(启用show perf monitor )时,它显示我的RAM被耗尽,直到该应用程序无法使用为止。

我的屏幕是这样的:


    const StacksOverTabs = createStackNavigator(
      {
        Root: {
          screen: TabNav,
          headerMode: 'none',
          navigationOptions: {
            header: null
          }
        },
        ScreenB: {
          screen: ScreenB,
        },
      }
    )

我通过执行this.props.navigation.navigate('ScreenB');从TabNav内部的TabNav进入ScreenB this.props.navigation.navigate('ScreenB'); ,然后在ScreenB称为this.props.navigation.goBack()

如果我使用pop()而不是goBack() ,问题是相同的,但在使用StackActions.reset时已StackActions.reset

我该如何调试导致无限循环的原因? 当我不使用goBack转到goBack ,没有性能问题。

问题似乎是我在ScreenB中的TextInput上具有onEndEditing! 由于某些原因,当与goBack结合使用时会导致无限循环!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM