This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-06
Channels
- # aleph (13)
- # announcements (1)
- # babashka (89)
- # beginners (23)
- # calva (14)
- # circleci (7)
- # clj-kondo (39)
- # clj-on-windows (1)
- # cljdoc (5)
- # cljsrn (29)
- # clojure (98)
- # clojure-art (3)
- # clojure-conj (5)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (9)
- # clojurescript (18)
- # clr (39)
- # code-art (3)
- # community-development (3)
- # cursive (3)
- # emacs (11)
- # events (1)
- # fulcro (12)
- # graalvm-mobile (16)
- # graphql (3)
- # gratitude (1)
- # honeysql (19)
- # java (7)
- # joyride (23)
- # lsp (22)
- # malli (2)
- # missionary (25)
- # off-topic (15)
- # polylith (15)
- # rdf (5)
- # reagent (9)
- # reitit (3)
- # scittle (3)
- # shadow-cljs (37)
- # slack-help (2)
- # sql (10)
I’ve found myself doing this for function components:
(defn FunctionComponent* [opts] ,,)
(defn Component [opts]
[:f> FunctionComponent* opts])
is there a cleaner way to define a function component (that can use hooks etc) in one shot, without the extra wrapper to pass :f>
?You can just invoke the function as reagent will leave non-vectors&non-functions untouched (https://github.com/reagent-project/reagent/blob/e67d4f8804c109868469d6e81ecd7184cf707575/src/reagent/impl/component.cljs#L100)
(defn Component [opts]
(FunctionComponent* opts))
Apart from that, it also probably prevents ratoms from working properly in such a function component.
another option is enabling function components as the default output: https://github.com/reagent-project/reagent/blob/master/doc/ReagentCompiler.md
@U051V5LLP in this case I am writing a library of components, so I would like to provide something easy for the user
the “solution” I posted before is definitely the nicest thing for the end user, but I have to define both of these components, and explain why there are two or hide one from the user