【发布时间】:2020-03-24 13:54:44
【问题描述】:
我正在尝试使用 Expo 和 Clojurescript 创建一个简单的地图应用程序,但是当我尝试渲染地图时出现以下错误:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
这就是代码的样子:
(ns map-test.core
(:require [reagent.core :as r :refer [atom]]
[re-frame.core :refer [subscribe dispatch dispatch-sync]]
[oops.core :refer [ocall]]
[map-test.handlers]
[map-test.subs]))
(def ReactNative (js/require "react-native"))
(def expo (js/require "expo"))
(def view (r/adapt-react-class (.-View ReactNative)))
(def text (r/adapt-react-class (.-Text ReactNative)))
(def MapView (js/require "react-native-maps"))
(def map-view (r/adapt-react-class MapView))
(defn app-root []
[view {:style {:flex 1}}
[map-view]])
(defn init []
(dispatch-sync [:initialize-db])
(ocall expo "registerRootComponent" (r/reactify-component app-root)))
这是我的package.json:
{
"name": "map-test",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"main": "main.js",
"dependencies": {
"expo": "^34.0.3",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
"create-react-class": "15.6.3",
"react-native-maps": "~0.24.0"
}
}
我尝试按照此处显示的答案进行操作:Using React Native MapView in ClojureScript Reagent,但它似乎不起作用。
感谢所有帮助!
【问题讨论】:
标签: react-native expo clojurescript react-native-maps reagent