reactjs - 我在使用 react-native-maps 参考时遇到问题
问题描述
我正在使用功能组件并在 MapView 组件中使用 useRef。但是这些功能不是通过参考来的,有人知道如何纠正吗?
代码示例
import React, {useRef} from 'react' //version 16.13.1
import MapView from 'react-native-maps' //version 0.27.1
import {View} from 'react-native' //version 0.63.2
const Map = () => {
const mapRef = useRef(null);
return (
<View>
<MapView ref={mapRef}/>
</View>
)
}
当我尝试访问 mapRef.current、fitToCoodinates、getCamera、animateToRegion 等时......未定义。但我可以从 mapRef.current 获得道具。有人能帮我吗?我想要功能,而不是属性。
解决方案
推荐阅读
- sql - 从应用脚本查询计算机上的数据库
- javascript - 特定的 React 模型有时不会加载,需要重新渲染
- javascript - 尝试在 React 中实现脚本
- ruby-on-rails - 我可以将 PGOPTIONS 环境变量用于 ruby on rails rails postgresql 会话吗?
- c++ - 我应该担心 SIG35 吗?
- excel - 将值复制/粘贴到 Excel 中的另一个工作表而不激活工作表
- nfs - Onos 3 节点 + Atomix 3 节点集群,NFS 上具有持久性卷
- android - 恢复安装在 Android 模拟器 (Flutter) 上的应用程序的源代码
- java - Eclipse Vert.x:用杰克逊解析 java.time 日期
- android - Android:即使应用程序未运行也显示消息通知