Fork me on GitHub

I am a bit lost on how to write best default props. I am using material ui AutoComplete. This has props such as autoComplete which is set to false as default. I would like to invert this and have a different, more specific component but still general, that is called PredictiveInput and it has autoComplete by default set to true. Then, I would like to be able to use ($ PredictiveInput ...) without specifying autoComplete for when it is true, and ($ PredictiveInput {:autoComplete false ...}) when I want to turn it off. The only problem is that in PredictiveInput component I am now writing stuff like ($ AutoComplete {:autoComplete (if (not (nil? auto-complete)) auto-complete true) and because there are several of these options that I would like to configure, it's a bit heavy, too much repetition, hard to see what is going on.


do Clojure destructuring defaults work for this case?


(defnc predictive-input
  [{:keys [auto-complete]
    :or {auto-complete true}]

👍 3

That's how I've been doing it


thanks, I am totally new to this