Fork me on GitHub
Sam Ritchie17:01:56

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 (

(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:

Sam Ritchie17:01:57

@U051V5LLP in this case I am writing a library of components, so I would like to provide something easy for the user

Sam Ritchie17:01:31

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