hey @lilactown I’m struggling to get the macros working to generate react native components
This works:
#?(:clj
(defmacro View [& args]
`(hx/$ ~(symbol "rn" "View") ~@args)))
#?(:clj
(defmacro Text [& args]
`(hx/$ ~(symbol "rn" "Text") ~@args)))
#?(:clj
(defmacro ActivityIndicator [& args]
`(hx/$ ~(symbol "rn" "ActivityIndicator") ~@args)))
but every time I try to do the loop I get some kind of mad error
any ideas?
ah, this seems to work
#?(:clj
(defn gen-tag
[t]
`(defmacro ~t [& args#]
`(hx/$ ~(symbol "rn" ~(str t)) ~@args#))))
#?(:clj
(defmacro gen-tags
[]
`(do
~@(for [t tags]
(gen-tag t)))))
#?(:clj
(gen-tags))
(where tags = '[View Text ActivityIndicator…]
)
Cool
Although that might not work quite right for React Native
It won’t convert kebab-case props to camelCase for you, and it won’t recursively convert the “style” prop to a JS obj