Fork me on GitHub

for props that don't have a label such as isRequired should I assume it should be put into the props map like: {isRequired: true} or more likely {is-required: true}? What about setting defaults? Right now I'm just doing something like (or (:title props) "My Title") but not sure if there is a more official way.


Yes, flag attributes have boolean values in Reagent. {:is-required true} and {:isRequired true} are both fine, but it's more common to use the former, the so-called kebab-case. Regarding the defaults - it depends. If it's "use the value if the key is not in the map", then you can either destructure the property somewhere with :or or use the second argument to either get or a keyword function, like (get props :title "My Title") or (:title props "My Title"). And if it's "use the value if the current value is nil" then your approach is the right one.


Ahh, I forgot about :or , thank you

👍 1