我使用Navigator来在页面之间导航.

当调用Navigator.push()方法时,"componentWillUnmount"方法不会在我们导航的页面上被调用.

这有点问题,因为我想取消听众的订阅,等等.

这是正常行为吗?

推荐答案

Navigator使用堆栈到管理器路由.当你按下new page时,当前页面不会卸载,如果你从new page跳到current pagenew page将卸载.

React-native相关问答推荐

什么是 expoClientId?

React Native:任务 ':app:checkDebugDuplicateClasses' 执行失败

React Native 应用程序没有在之前的工作代码中执行任何操作就无法运行

react native HTML entities

react-native react-native-vector-icons:如何使用字体真棒图标

如何在 React Native 的嵌套 Touchable 中传播touch 事件?

TabNavigator 中的 React Navigation 传递props

给定 APK 文件,我如何检测应用程序是否使用 React Native?

你能在 Ubuntu 上构建 React Native 应用程序(Android 应用程序)吗?

如何解决此错误您可能需要适当的加载程序来处理此文件类型

cmd : react-native run-android 在每次文件更改时

如何解决react-navigation 问题:Animated: `useNativeDriver` is not supported because the native animated module is missing.?

自定义原生基础的选项卡

如何在 React Native 中获取电话号码?

在不使用 3rd 方库的情况下,在react-native中显示主屏幕之前显示启动画面

Xcode 12 - 没有要编译的架构(ONLY_ACTIVE_ARCH=YES,active arch=x86_64,VALID_ARCHS=arm64e armv7s arm64 arm7)

如何将 React-Native 元素集成到 Android-Studio?

将现有的 React Native 项目转换为 Expo

React Native - 导航问题undefined is not an object (this.props.navigation.navigate)

React-Native 水平滚动视图分页:预览下一页/卡片