fulcro

Lem Wild 2025-12-13T10:40:00.591219Z

Hello everyone. I am going through "Fulcro 3 Tutorial" series on Youtube, and so far so good, but I can't seem to understand the reason why a ".. does not INCLUDE initial state for .." warning is printed to console when a template-notation :initial-state structure is specified while everything still works as expected, and why using a seemingly equivalent lambda-notation does not result in any warning being printed to console. Here's an example with comments near the relevant code:

;; in file: client.cljs

(defsc Car [this {:keys [car/id car/model] :as props}]
  {:query [:car/id :car/model]
   :ident :car/id
   :initial-state {:car/id :param/init-id
                   :car/model :param/init-model}}
  (println "\n\nprops on cars" props)
  (dom/div
   "Model: " model))

(def ui-car (comp/factory Car {:keyfn :car/id}))


(defsc Person [this {:person/keys [id name cars] :as props}]
  {:query [:person/id :person/name {:person/cars (comp/get-query Car)}]
   :ident :person/id
   :initial-state
   ;;
   ;; template-notation (everything works as expected, but a warning is printed to console):
   ;;
   {:person/id :param/id
    :person/name :param/name
    :person/cars :param/cars}
   ;;
   ;; Example with lambda-notation (everything works, and no warning is printed to console):
   ;;
   ;; (fn [{:keys [id name cars]}]
   ;;   {:person/id id
   ;;    :person/name name
   ;;    :person/cars cars})
   ;;
   }
  (println "\n\nThese are cars:" cars)
  (dom/div
   (dom/div "Name: " name)
   (dom/ul
    (map ui-car cars))))

(def ui-person (comp/factory Person {:keyfn :person/id}))


(defonce APP (app/fulcro-app))


(defsc root-elem [this {:keys [root-key] :as props}]
  {:query [{:root-key (comp/get-query Person)}]
   :initial-state (fn [params]
                    {:root-key
                     (comp/get-initial-state Person
                                             {:id 1
                                              :name "Bob"
                                              :cars
                                              [(comp/get-initial-state Car {:init-id 123
                                                                            :init-model "first"})
                                               (comp/get-initial-state Car {:init-id 124
                                                                            :init-model "second"})]})})}
  (println "passing this state" root-key)
  (dom/div
   (ui-person root-key)))



(defn ^:export init []
  (it/add-fulcro-inspect! APP)
  (app/mount!
   APP
   root-elem
   "app"))