react-native - 带有 useEffect 的 useFocusEffect 随机返回警告“不支持 'route' 对象的属性”
问题描述
我有这个效果,它在离开屏幕时设置一个状态。当状态设置为空时,它会触发一个关闭底部工作表的函数(警报)
useFocusEffect(
React.useCallback(() => {
return () => {
setAlert(null);
};
}, [setAlert])
我在移动到另一个屏幕时随机收到此警告**,而警报底部表打开**:Accessing the 'state' property of the 'route' object is not supported. If you want to get the focused route name, use the 'getFocusedRouteNameFromRoute' helper instead: https://reactnavigation.org/docs/screen-options-resolution/#setting-parent-screen-options-based-on-child-navigators-state
当我禁用它useFocusEffect
时,警告就会消失。
我究竟做错了什么?
解决方案
推荐阅读
- python - 在 AWS Lambda 上使用 BeautifulSoup 抓取 Amazon
- javascript - TypeError:“调用者”、“被调用者”和“参数”属性可能无法在严格模式函数或调用的参数对象上访问
- ios - 如何为 Apple Silicon arm64 模拟器构建 xcframework?
- ffmpeg - ffmpeg透视滤镜动画错误
- linux - 具有 16 个前导二进制字节的文本文件是“正常”文件格式吗?
- google-cloud-firestore - Cloud Firestore 安全规则,不适用于智能手机
- java - 我收到一条错误消息,提示无法找到或加载主类 com.company.main - java 初学者和 intellij 寻求指导
- java - 在 EJB 2.0 中,何时将 CMP 实体 bean 持久化到数据库?
- eclipse - model.ecore 在 maven 'clean install' 目标期间未生成 project\target\classes\package\gen\model\impl
- c++ - 为什么我们在从向量中删除时需要递减迭代器?