问题描述
我正在导入反应组件(使用: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*])))
这对于开发工作正常,但是在启用高级编译器后:
最小回购: https://github.com/fbielejec/npm-deps-demo
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"]])))
I'm importing a react component (using the :npm-deps support) and wrapping with the adapt-react-class adapter:
(: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*])))
This works fine for development, but when advanced compiler is on:
Minimimal repo:https://github.com/fbielejec/npm-deps-demo
meta-tags*
is a class, but you're trying to call it like a function by placing it inside the Reagent square braces i.e. meta-tags*
.
In the source code that you posted on GitHub, you also define a function called meta-tags
. It looks like you're accidentally calling meta-tags*
by mistake. Your full code (based on the Github demo) should read:
(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"]])))
这篇关于试剂/适配器反应类由于:optimizations:advanced失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!