helix

https://github.com/Lokeh/helix
Aron 2020-09-11T13:30:16.053800Z

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.

lilactown 2020-09-11T16:48:48.054200Z

do Clojure destructuring defaults work for this case?

lilactown 2020-09-11T16:49:19.055Z

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

👍 1
dominicm 2020-09-11T16:58:19.055500Z

That's how I've been doing it

Aron 2020-09-11T23:28:22.055800Z

thanks, I am totally new to this