试剂/适应反应类失败:优化:高级

时间:2017-11-13 19:53:35

标签: reactjs clojurescript reagent

我导入react component(使用:npm-deps支持)并使用adapt-react-class适配器包装:

(:require [reagent.core :as reagent]
          [react-helmet]) 

(def meta-tags* (reagent/adapt-react-class (aget react-helmet "default")))

(defn main-panel []
  (let []
    (fn []
      [meta-tags*])))

这适用于开发,但是当打开高级编译器时:

  

未捕获的TypeError:无法将类作为函数调用

最小回购: https://github.com/fbielejec/npm-deps-demo

1 个答案:

答案 0 :(得分:0)

meta-tags*是一个类,但是你试图把它称为函数,方法是将它放在Reagent方括号中,即meta-tags*

在GitHub上发布的源代码中,您还定义了一个名为meta-tags的函数。看起来你错误地打电话给meta-tags*。您的完整代码(基于Github演示)应为:

(ns app.views
  (:require [reagent.core :as reagent]
            [react-helmet]))

(def meta-tags* (reagent/adapt-react-class (aget react-helmet "default")))

(defn meta-tags [{:keys [:title :description]
                  :or {title "Some title"
                       description "some description"}}]
  [meta-tags* {:id "app-meta-tags"}
   [:title {:id "title" :title title}]
   [:meta {:id "description" :content description}]])

(defn main-panel []
  (let []
    (fn []
      [:div.container
       [meta-tags] ; <- no * star!
       [:h1 "Check for the meta-tags presence"]])))