Sometimes you get a JS object and want to forward it as props to a component.
What we'd like to do:
(defnc my-component []
;; `some-lib/Foo` is an external lib that uses a common pattern:
;; pass it a function-as-children which it then passes props to as a JS object
($ some-lib/Foo
(fn [foo-props]
(d/div {& foo-props} "I'm so foo-y!"))))
Currently, this requires converting or wrapping foo-props so that it is a CLJS map-alike, so that spread props works.
(defnc my-component []
($ some-lib/Foo
(fn [foo-props]
;; wrap it in a bean, so that it can then be converted into a JS obj again... :sad:
(d/div {& (cljs-bean.core/bean foo-props)} "I'm so foo-y!"))))
To support writing spread props like in the first snippet, spread props should check to see if it's a map-alike and if not, fall back to merging it in by Object.keys.
Sometimes you get a JS object and want to forward it as props to a component.
What we'd like to do:
Currently, this requires converting or wrapping
foo-props
so that it is a CLJS map-alike, so that spread props works.To support writing spread props like in the first snippet, spread props should check to see if it's a map-alike and if not, fall back to merging it in by
Object.keys
.