This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-15
Channels
- # admin-announcements (2)
- # beginners (93)
- # boot (34)
- # capetown (1)
- # cider (15)
- # cljs-dev (30)
- # cljsjs (9)
- # clojars (8)
- # clojure (199)
- # clojure-austin (3)
- # clojure-france (3)
- # clojure-greece (2)
- # clojure-italy (46)
- # clojure-quebec (7)
- # clojure-russia (2)
- # clojure-spec (76)
- # clojure-uk (16)
- # clojurescript (43)
- # core-async (7)
- # cursive (14)
- # data-science (1)
- # datascript (4)
- # datomic (3)
- # devcards (60)
- # editors (5)
- # funcool (5)
- # garden (3)
- # hoplon (32)
- # immutant (22)
- # jobs (1)
- # lein-figwheel (21)
- # leiningen (1)
- # mental-health (11)
- # mount (2)
- # off-topic (6)
- # om (16)
- # onyx (15)
- # re-frame (43)
- # reagent (20)
- # rum (18)
- # specter (37)
- # sql (2)
- # testing (8)
- # untangled (7)
- # yada (19)
Hey all, I’m upgrading dependencies, and I’m getting a Something is calling a React component directly. Use a factory or JSX instead
warning. Google led me to some examples that seemed more specific than I needed. Here’s the code:
(let [html (vis/get-html vis response)
js (vis/get-js vis response)
reagent-comp (reagent/create-class
(merge {:component-function #(views/main-page html)}
(if js {:component-did-mount js} {})))]
(reagent/render reagent-comp (.getElementById js/document "app")))
views/main-page
is just a function returning a hiccup tree with the passed-in html at the bottom
🦆 For those finding this in a log somewhere with the same problem, using with-meta
like the reagent docs say (instead of following the re-frame doc like I was doing) fixes the issue
If I define reagent-comp as (if js (with-meta #(views/main-page html) {:component-did-mount js}) #(views/main-page html))
then everything’s wonderful
@snowell: you could try (reagent/render [reagent-comp] (.getElementById js/document "app”))