I would like to do something similar to Reagent form-3 components, which enable me to define some shared (static) vars to use in lifecycle functions.
Basically my question is how do I construct something equivalent to the let
in the Reagent code snippet below? I can't seem to figure out how to do this properly using Om's defui
macro.
A simple example would be to generate an internal id I can access in all lifecycle functions of a specific instance of my component via gdom/getElement
.
(defn my-component
[x y z]
(let [id (gensym "my-component-")] ;; <-- how to do this in Om?
(reagent/create-class
{:component-did-mount (...)
:component-will-mount (...)
:reagent-render
(fn [x y z] (js/console.log id)))) ;; <-- id is available