javascript - 反应原生聆听组件的选项卡更改?
问题描述
在 React Native 中是否可以监听组件中的选项卡更改?
useEffect(() => {
return () => console.log('unmount?')
}, [navigation])
当我更改选项卡并离开组件时,有什么可以检测到的使用效果吗?我猜它没有卸载,但我需要知道用户何时离开屏幕
解决方案
You can use
navigation.isFocused
to know which screen is focussed
推荐阅读
- java - 如何在java中垂直绘制图形?
- css - Vuetify - 在 v-card 中水平居中 v-progress-linear
- xml - 根据关键字/分隔符将元素中的文本拆分为多个元素
- python - 使用来自环境而不是数据库的气流连接
- python - 如何将文本清理步骤压缩为单个 Python 函数?
- kubernetes - 对 config-autoscaler configmap 的编辑会在应用更改后几分钟自动恢复
- ios - iOS - 应用程序终止时开始监控重大位置变化 - 不工作
- google-apps-script - Google 表单将“文件上传”文件重命名为“问题 - 提交者”
- r - 通过r中的pairwiseAlignment比较两个序列列表的每个序列
- cakephp - CakePhp 3 - 如何扩展一个助手