hi, I'm a newbie. I don't know what the Om component
means in om/component?
(defui HelloWorld
Object
(render [this]
(dom/div nil "Hello, world!")))
(def hello (om/factory HelloWorld))
I tried:
(om/component? HelloWorld)
(om/component? hello)
Both commands returned false
@minhnh om/component?
actually checks for a component instance. For example,
(defui HelloWorld
Object
(render [this]
(println (om/component? this))
(dom/div nil "Hello, world!")))
;; true
How can I get this
outside render
function
If you’re using the repl, you can go (om/component? (om/class->any reconciler HelloWorld))
om/class->any
asks the reconciler for some instance (if there are several instances, it’ll return one of them) of the HelloWorld
class.
If you’re looking for a specific instance,
(om/component? (om/ref->any reconciler [:something/by-id 0]))
, where [:something/by-id 0]
is an ident
👍 This is what I need. Thank you
you’re welcome. ref->any can do more, but I’ll just leave this here for brevity. https://github.com/omcljs/om/wiki/Documentation-(om.next)#ref-any