(defnc MyComponent[{:keys [variant class-name class]
:or {variant :down class "foo" class-name "bar"}}]
(println "class" (if class class "CLASS NOT TRUTHY"))
(println "classname" (if class-name class-name "CLASSNAME NOT TRUTHY"))
[:div "something"])
When invoking the above code like:
[MyComponent {:variant :up}]
The following is printed:
class CLASS NOT TRUTHY
classname bar
But when invoking it with:
[MyComponent {:class "hx-rocks"}]
class hx-rocks
classname hx-rocks
It seems that :class is set unconditionally to nil in that map, so that the keys destructuring doesn't work. I made this small repro using plain ClojureScript to make sure:
(defn TEST [{:keys [a b] :or {a 1 b 2}}]
(println "A" a "B" b))
(TEST {:a nil})
When invoking the above code like:
The following is printed:
But when invoking it with:
It seems that :class is set unconditionally to
nil
in that map, so that the keys destructuring doesn't work. I made this small repro using plain ClojureScript to make sure:This prints:
A nil B 2
.