fulcrologic / fulcro

A library for development of single-page full-stack web applications in clj/cljs
http://fulcro.fulcrologic.com
MIT License
1.54k stars 137 forks source link

Link/ident queries don't work with `false` values #543

Closed joncurrier closed 1 year ago

joncurrier commented 1 year ago

When using a link or ident query, nothing is returned when the value at the queried-for ident is false. For example, in the example below, the Child component will receive an empty props map instead of the expected {:root/pred? false} and will therefore render nothing instead of "false":

(defsc Child [this {:keys [root/pred?]}]
  {:query         [[:root/pred? '_]]
   :initial-state {}}
  (dom/div (str pred?)))

(def ui-child (comp/factory Child))

(defsc Root [this {:keys [root/pred? child]}]
  {:query         [:root/pred? {:child (comp/get-query Child)}]
   :initial-state (fn [_] {:root/pred? false
                           :child (comp/get-initial-state Child)})}
  (ui-child child))

In use cases where we only care about truthy values for the prop, this won't matter, but it becomes relevant when there's a meaningful distinction between false and nil or missing values.