Fork me on GitHub

Is there a standard way to use adapt-react-class on many components?

(def Card (reagent/adapt-react-class js/MaterialUI.Card))
(def CardActions (reagent/adapt-react-class js/MaterialUI.CardActions))
(def CardContent (reagent/adapt-react-class js/MaterialUI.CardContent))
I tried to define a macro where I can say (load-material-ui-component Button) and it will expand to Code (def Button (reagent/adapt-react-class js/MaterialUI.Button)) Can you see if there is an error in my macro definition or is this just not possible with macros at compile time in cljs?
(defmacro load-material-ui-component
  `(def ~(symbol component-name)
     (reagent/adapt-react-class ~(symbol (str "js/MaterialUI." component-name)))))


The macro approach should be fine. I’ve had somewhat similar macros for the same idea.


As long as you define your macro correctly and in a clj/cljc ns and include it


I’m not sure what specific issues you are getting with trying that


Thanks for your answer. I defined that macro in a cljs file and did some other mistakes.. fixed that, now its working 😁


I can’t help you with your macro, but apparently you can directly write [:> js/MaterialUI.CardActions]