This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-26
Channels
- # announcements (1)
- # asami (7)
- # aws (3)
- # babashka (30)
- # beginners (21)
- # calva (48)
- # cider (11)
- # clj-commons (5)
- # clj-kondo (12)
- # cljdoc (5)
- # cljfx (1)
- # cljs-dev (32)
- # cljsrn (4)
- # clojure (218)
- # clojure-europe (88)
- # clojure-nl (11)
- # clojure-uk (31)
- # clojurescript (8)
- # cursive (98)
- # data-science (6)
- # datomic (49)
- # emacs (12)
- # events (4)
- # fulcro (47)
- # graalvm (3)
- # graphql (4)
- # introduce-yourself (5)
- # java (13)
- # juxt (9)
- # lsp (74)
- # meander (3)
- # membrane (4)
- # missionary (31)
- # off-topic (24)
- # pathom (41)
- # portal (4)
- # reagent (3)
- # releases (1)
- # remote-jobs (3)
- # rewrite-clj (4)
- # shadow-cljs (10)
- # slack-help (2)
- # testing (20)
- # tools-deps (43)
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.