Fork me on GitHub

I shared this in the re-frame channel but I thought I'd share it here too, half in case it's useful to anyone else, and half in case someone can point out some flaws: - it's an implementation of use-sub for using re-frame subs as react hooks.


Hi, why is ^:native is causing Error: [object Object] is not ISeqable when I'm accessing the (.-button theme) but not when using keyword (:button theme) ... Then why removing ^:native metadata and accessing (.-button theme) works?

value of theme #js {:button #js {:color #6b46c1}, :input #js {:color #4a5568, :borderColor #cbd5e0, :borderWidth 1, :height 40}}

(defnc button [{:keys [on-press data-testid title color]}]
  (let [theme (useTheme)]
    (println "theme " theme)
    ($ rn/Button {:style (.-button theme) <------------ seems like (.-button theme) causes error when adding ^:native
                  :color (.. theme -button -color)
                  :title title
                  :on-press on-press
                  :data-testid data-testid})))


After experimenting a bit, I think the issue is ^:native requires cljs map and not js object... (.-button theme) returns js object, hence the error? The reason (:button theme) works with ^:native metadata is because it returns nil?