taoensso.tengen.reagent
cmptfn
macro
(cmptfn id params & args)
Reagent component fn util. Provides a sensible let-flow API for writing
simple, flexible Clj/s Reagent components.
(cmptfn
id ; Component identifier for debugging, error reporting, etc.
[x y] ; Reagent args passed to component
:let-mount [] ; Est. with each instance mount, avail. downstream
:let-render [] ; Est. with each instance render, avail. downstream, pure!
:render <body> ; Or just provide render body as final arg, pure!
:post-render <body> ; For DOM node setup/mutation
:unmount <body> ; For DOM node teardown
)
- Magic bindings: `this-cmpt`, `this-mounting?`.
- Nodes: `[<cmpt> {:ref (fn [node] _)}]` or `(enc/oget ev "currentTarget")`.
- Call Reagent components as:
* (<cmpt> <...>) - to get inlining.
* [<cmpt> <...>] - to get an intermediary Reagent component:
* Rerender-iff-args-change semantics.
* Can take ^{:key _} [<cmpt> <...>].
def-cmptfn
macro
(def-cmptfn sym & sigs)
Defines a top-level Reagent component fn using `cmptfn`.
See the `cmptfn` docstring for more details on args, etc.