fulcrologic/fulcro-inspect

`nil` running through props

chrismurrph opened this issue · 1 comments

(ns applets.inspect-bug.core
  (:require [fulcro.client :as fc]
            [fulcro.client.primitives :as prim :refer [defsc]]
            [fulcro.client.dom :as dom]))

(defonce app (atom nil))

(defsc Business [_ {:business/keys [favorite-food]}]
  {:initial-state (fn [_] {:business/favorite-food "lolly-pops"})
   :query [:business/favorite-food]}
  (assert (string? favorite-food))
  (dom/p (str "In this business the favourite food is " favorite-food)))

(defsc BusinessRoot [this _]
       {:initial-state (fn [_] {:ui/root (prim/get-initial-state Business _)})
        :query         [{:ui/root (prim/get-query Business)}]}
       (let [{:ui/keys [root]} (prim/props this)]
         (dom/div ((prim/factory Business) root))))

(defn mount []
  (reset! app (fc/mount @app BusinessRoot "app")))

(defn ^:export init [_]
  (reset! app (fc/new-fulcro-client))
  (mount))

So the above code works fine. But when you introduce Fulcro Inspect and press the key that toggles the tool's visibility you get a big stack trace. I won't include the full thing, but these lines might help:

core.cljs:11 Uncaught Error: Assert failed: (string? favorite-food)
...
fulcro.client.primitives.force_update.cljs$core$IFn$_invoke$arity$2 @ primitives.cljc:2045
fulcro$client$primitives$force_update @ primitives.cljc:2041
fulcro.client.primitives.force_update.cljs$core$IFn$_invoke$arity$1 @ primitives.cljc:2049
fulcro$client$primitives$force_update @ primitives.cljc:2041
fulcro$client$primitives$update_component_BANG_ @ primitives.cljc:2069
fulcro$client$primitives$optimal_render @ primitives.cljc:2114
fulcro.client.primitives.Reconciler.fulcro$client$impl$protocols$IReconciler$reconcile_BANG_$arity$2 @ primitives.cljc:2257
fulcro.client.impl.protocols.reconcile_BANG_.cljs$core$IFn$_invoke$arity$2 @ protocols.cljc:23
fulcro$client$impl$protocols$reconcile_BANG_ @ protocols.cljc:11
fulcro.client.primitives.Reconciler.fulcro$client$impl$protocols$IReconciler$reconcile_BANG_$arity$1 @ primitives.cljc:2232
fulcro.client.impl.protocols.reconcile_BANG_.cljs$core$IFn$_invoke$arity$1 @ protocols.cljc:23
fulcro$client$impl$protocols$reconcile_BANG_ @ protocols.cljc:11
(anonymous) @ primitives.cljc:1971
requestAnimationFrame (async)
fulcro$client$primitives$queue_render_BANG_ @ primitives.cljc:1966
fulcro$client$primitives$schedule_render_BANG_ @ primitives.cljc:1971
fulcro$client$primitives$add_fn @ primitives.cljc:2191
cljs.core.Atom.cljs$core$IWatchable$_notify_watches$arity$3 @ core.cljs:4394

There is no shortcut on new versions due to the new architecture, please reopen if that somehow still a problem after that.