diff --git a/examples/workshop/core.cljs b/examples/workshop/core.cljs index 66439c0..cf8e300 100644 --- a/examples/workshop/core.cljs +++ b/examples/workshop/core.cljs @@ -154,3 +154,13 @@ [PostCond {:age 19}]] [ErrorBoundary [PostCond {:age 42}]]])) + +(hx/defnc ClassNameProp [{:keys [class class-name]}] + [:<> + [:ul + [:li "class: \"" class "\""] + [:li "class-name: \"" class-name "\""]] + (str (= class class-name))]) + +(dc/defcard class-name-prop + (hx/f [ClassNameProp {:class "foo"}])) diff --git a/src/hx/react.cljc b/src/hx/react.cljc index d8306a1..4040eed 100644 --- a/src/hx/react.cljc +++ b/src/hx/react.cljc @@ -45,7 +45,7 @@ ret (gensym "return_value")] ;; maybe-ref for react/forwardRef support `(defn ~name [props# maybe-ref#] - (let [~props-bindings (hx.react/props->clj props# maybe-ref#)] + (let [~props-bindings [(hx.react/props->clj props#) maybe-ref#]] ;; pre-conditions ~@(when (and opts-map? (:pre (first body))) (map (fn [x] `(assert ~x)) (:pre (first body)))) @@ -78,9 +78,10 @@ args))) -#?(:cljs (defn props->clj [props maybe-ref] +#?(:cljs (defn props->clj [props] (let [props (utils/shallow-js->clj props :keywordize-keys true)] - [props maybe-ref]))) + ;; provide `:class-name` property also as `:class` + (assoc props :class (:class-name props))))) #?(:clj (defn $ [el & args] nil)