This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-14
Channels
- # beginners (19)
- # boot (11)
- # cider (59)
- # cljs-dev (292)
- # cljsrn (2)
- # clojure (121)
- # clojure-brasil (19)
- # clojure-canada (2)
- # clojure-france (2)
- # clojure-italy (57)
- # clojure-spec (54)
- # clojure-uk (20)
- # clojurescript (83)
- # core-async (20)
- # cursive (5)
- # datascript (2)
- # datomic (10)
- # duct (25)
- # editors (4)
- # emacs (2)
- # fulcro (5)
- # funcool (1)
- # graphql (2)
- # immutant (8)
- # java (1)
- # jobs (4)
- # jvm (1)
- # keechma (5)
- # luminus (10)
- # off-topic (113)
- # om (36)
- # onyx (11)
- # parinfer (55)
- # pedestal (7)
- # protorepl (28)
- # re-frame (25)
- # reagent (6)
- # ring-swagger (1)
- # shadow-cljs (113)
- # spacemacs (1)
- # specter (23)
- # unrepl (8)
- # yada (8)
Hey all, I'm getting a random error "Cannot read property 'call' of null" with no line number for my root component. What should I do?
(ns bakery-app.components.root-component
(:require [re-frame.core :as re-frame]
[bakery-app.reframe.subs :as subs]
[reagent.core :as reagent]
[bakery-app.reframe.events :as events]
[bakery-app.reframe.handlers :as handlers]
[bakery-app.components.container.product-list :as product-list]
[bakery-app.components.container.shopping-cart :as shopping-cart]
))
(defn root-component []
(let [name (re-frame/subscribe [::subs/name])]
(reagent/create-class ;; <-- expects a map of functions
{:component-did-mount ;; the name of a lifecycle function
#((re-frame/dispatch [::handlers/load-product-list]))
;; other lifecycle funcs can go in here
:display-name "mail-panel" ;; for more helpful warnings & errors
:render ;; Note: is not :render
(fn [] ;; remember to repeat parameters
[:div {:class "root-component"}
[product-list/product-list-component]
[shopping-cart/shopping-cart-component]
]
)})))
and my core.cljs
(ns bakery-app.core
(:require [reagent.core :as reagent]
[re-frame.core :as re-frame]
[bakery-app.reframe.events :as events]
[bakery-app.components.root-component :as view]
[bakery-app.config :as config]
[bakery-app.reframe.handlers :as handlers]))
(defn dev-setup []
(when config/debug?
(enable-console-print!)
(println "dev mode")))
(defn mount-root []
(re-frame/clear-subscription-cache!)
(reagent/render [view/root-component]
(.getElementById js/document "app")))
(defn ^:export init []
(re-frame/dispatch-sync [::events/initialize-db])
(dev-setup)
(mount-root))
I think I figured it out actually
the component-did-mount seems to like (fn [] (re-frame/dispatch [::handlers/load-product-list])) vs the shortcut #()