Fork me on GitHub

Hi everyone. New at reagent. I defined a component, giving it a :name prop. Something like

(defn my-comp [name] [:h1#title {:name name} name])
. Elsewhere in code, I setup a click event listener for that component:
(dommy/listen! (dommy/sel1 "#title") :click clicked)
. How do I access the :name prop from inside the event handler?
(defn clicked [] ...)


does dommy know anything about reagent? never used that library before


usually id directly attach an on-click to the h1


(defn my-comp [name] [:h1#title {:on-click (build-click-handler-fn name)} name])


I want to keep the listening/handling separate from the component. Reason why is because the handling requires knowledge of some part of state the component should not be aware of. i.e. separation of concerns


My listener is therefore (kind of) a mediator.


btw no dommy is only a helper lib for DOM element selection and event listener setup


just edited it a bit


since you're setting :name, you might be able to get it off the event that's passed to clicked


that's how you'd do it w/ jquery i think


usually these libraries pass the dom event to the event handler


Good hint. Not sure it's the idiomatic react/reagent way but barring no other options will look into that. Thx!


I'm having trouble finding a good explanation for how Hoplon and Reagent/Re-frame compare. I know Hoplon uses a "spreadsheet" metaphor with Javelin and doesn't use React, and Reagent uses FRP and React, but spreadsheets are sort of FRP, aren't they? How does the metaphor diverge? I want to make an app where much of the code I could reuse for the web, my phone, and the desktop, though this will most likely be a desktop-first app via Electron. I want to make a personal knowledge base (, so I want to be able to query and explore a multimedia graph database rendered in canvas or WebGL (I'm not sure of the GUI side yet, but the data structures side is pretty well-defined for me). I want to have the database be immutable and versioned, so I've been looking into using DataScript as the base for my database. How would DataScript fit into Hoplon or Reagent? Can you help me understand the pros and cons or differences between Hoplon and Reagent for someone who hasn't used React or ClojureScript before? I use JS a lot, but I don't have any real experience with the React or ClojureScript ecosystems nor even Clojure, so I don't quite know why I would want CLJS-flavored React any more than I know that I would want Javelin. I apologize for requesting such a comprehensive explanation from such ignorance. There's so much information to understand that it's difficult for a newcomer like me to make sense of it and make a good judgment on which framework/library is best for me. I have dabbled in different Lisps but haven't used any for real projects, though I've made a Lisp interpreter. I say this so you realize I'm not a complete newbie when it comes to Lisps in general, though I'm definitely a newbie to Clojure(Script).


@gamecubate: i'd look more at the reagent and reframe docs, attaching listeners like this is def not idomatic reagent


@jjfine Yes indeed I think I should. I may be making this more complex than it needs to be.