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))
The [:f> ...] part is a vector though.
oh i see now - that just "moves" the problem to every caller needing to know that
Apart from that, it also probably prevents ratoms from working properly in such a function component.
yea for sure
another option is enabling function components as the default output: https://github.com/reagent-project/reagent/blob/master/doc/ReagentCompiler.md
@danvingo 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