0

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:

Uncaught TypeError: Cannot call a class as a function

Minimimal repo: https://github.com/fbielejec/npm-deps-demo

1

1 Answer 1

0

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"]])))
2
  • Him thanks you for answering. I don't think this makes any dfference, the meta-tags function is just a wrapper around the adapted component. I just simplified the code snippet for the sake of brewity. The github code is 1-1 to what you pasted here.
    – fbielejec
    Nov 13, 2017 at 21:45
  • I tried further simplifying the minimal repo even more to github.com/VaclavSynacek/npm-deps-demo but still cannot get it to work. The trouble with met-tags* and meta-tags that Scott suggests are the problem are factored our, but still no working result.
    – Vasek
    Jun 6, 2018 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.