首页 > 解决方案 > nativeEvent 对象未出现在 React Native 中

问题描述

我正在尝试使用本机反应在我的移动应用程序上集成简单的地图,并希望获取用户在屏幕上点击的位置坐标。使用的库是以 MapView 作为组件的 react-native-maps。

当我尝试点击屏幕以获取点击区域的坐标时,如果我 console.log 在我的控制台上记录 onPress() 事件,则不会出现 nativeEvent 对象。相反,我得到了 "_nativeTag": 3,它没有出现在我搜索的许多教程和博客中。

请告诉此查询的任何解决方案或替代方案。

   SyntheticEvent {
   "_dispatchInstances": FiberNode {
    "tag": 5,
    "key": null,
    "type": "AIRMap",
  },
  "_dispatchListeners": [Function selectLocationHandler],
  "_targetInst": FiberNode {
    "tag": 5,
    "key": null,
    "type": "AIRMap",
  },
  "bubbles": undefined,
  "cancelable": undefined,
  "currentTarget": ReactNativeFiberHostComponent {
    "_children": Array [],
    "_internalFiberInstanceHandleDEV": FiberNode {
      "tag": 5,
      "key": null,
      "type": "AIRMap",
    },
    *****"_nativeTag": 3,*****
    "viewConfig": Object {
      "Commands": Object {
        "animateCamera": 12,
        "animateToBearing": 4,
        "animateToCoordinate": 2,
        "animateToNavigation": 9,
        "animateToRegion": 1,
        "animateToViewingAngle": 3,
        "fitToCoordinates": 7,
        "fitToElements": 5,
        "fitToSuppliedMarkers": 6,
        "setCamera": 11,
        "setIndoorActiveLevelIndex": 10,
        "setMapBoundaries": 8,
      },

标签: javascriptreactjsreact-nativegoogle-mapsmaps

解决方案


推荐阅读