react-native - 反应导航:useIsFocused 使用失败测试用例
问题描述
我将 useIsFocused() 添加到我的文件中以适应焦点事件,例如
文件.js
import { useIsFocused, useNavigation } from "@react-navigation/native"
const navigation = useNavigation()
const isFocused = useIsFocused()
useEffect(() => {
getData(somedata)
}, [isFocused])
但是当我运行我的测试文件时,测试失败了
TypeError: navigation.isFocused is not a function
我在这里错过了什么吗?
解决方案
推荐阅读
- php - CodeIgniter 应用程序 3 错误:分页无法正确呈现搜索结果?
- python - Pytorch:RuntimeError:mat1 dim 1 必须匹配 mat2 dim 0
- javascript - 访问模型内部的 Tensorflow.js 层属性
- java - 如何将此 Json 对象解析为 Java 对象?
- python - 提高套接字速度
- recursion - 如何使用递归乘以 N 个浮点数?
- reactjs - useEffect 导致无限循环
- java - 通过 Proxy、InvocationHandler 和自定义 Annotations 实现参数验证
- discord.js - 将 Discord.js v11 翻译成 v12
- c++ - 数据结构与算法(C++)