【发布时间】:2017-09-19 11:07:50
【问题描述】:
我正在尝试使用来自https://github.com/airbnb/react-native-maps 的MapView 使用试剂。它工作正常,但是当onRegionChange 事件被触发时,我怎样才能获得MapView 的本地状态?尝试使用当前/组件,但始终是 nil。
(def Expo (js/require "expo"))
(def map-view (r/adapt-react-class (.-MapView Expo)))
(defn my-map []
(r/create-class
{:component-did-mount (fn [this]
(println "component mount "))
:reagent-render (fn []
(let [this (r/current-component)]
[map-view {:style {:flex 1}
:initialRegion {:latitude 37.78825
:longitude -122.4324
:latitudeDelta 0.0922
:longitudeDelta 0.0421}
:onRegionChange (fn []
;; Would like to see state here.
(println (.. this -state)) )}]))}))
【问题讨论】:
-
你为什么需要 expo 并打电话给
.-MapView? -
这里是博览会文档以获取更多信息docs.expo.io/versions/latest/sdk/map-view.html
-
啊,谢谢。今晚我会看看它。
标签: react-native clojure android-mapview clojurescript reagent