android - React Native AppState 在带有模糊事件的 android 中不起作用
问题描述
当我在 android 上的下拉菜单中没有出现来自 AppState 的模糊和焦点事件,并且我找不到任何用例来触发它。有人知道如何解决这个问题以及为什么它不起作用?我在世博在线编辑器中尝试过模拟器,但同样的问题仍然存在。反应原生版本 0.63.3。这是我的代码:
const onBlur = () => {
console.log('blur is working')
}
useEffect(() => {
if (Platform.OS === 'android') {
AppState.addEventListener('blur', onBlur)
}
return () => {
if (Platform.OS === 'android') {
AppState.removeEventListener('blur', onBlur)
}
}
}, [])
解决方案
推荐阅读
- ruby-on-rails - Ruby on Rails - 在域中运行时应用程序无法正常工作
- android - 如何解决服务类中的“ANR 原因:执行服务”错误?
- python - 处理具有多个值的 pandas 列以进行数据分析
- php - 如果数组包含数组,则使用 Slim php 的 Restful api 返回空
- node.js - 在 nunjucks 中循环穿过 2 个物体
- android - 如何为android studio安装adb
- javascript - jQuery多步表单验证
- c++ - 在 C++20 获得批准之前,我应该如何使用 day-since-epoch 值?
- bookshelf.js - Bookshelf.js: one-to-many relationship setup
- python - Points inside polygon in PostGIS