Fork me on GitHub
Alexander Knemeyer11:09:21

Hi folks. I'm struggling to get :on-load working with svg in reagent. For example, [:svg {:on-mouse-down #(println "mouse down") :on-load #(println "loaded")}] prints "mouse down" when I click it but "loaded" never appears. For context (ie in case there's a better way, or I've found a bug) I'm trying to implement the draggable svg components in this tutorial except in cljs. Any ideas of what I'm doing wrong?


I don't see a use of a load event in that tutorial. Are you certain that svg has a load event?

Alexander Knemeyer12:09:58

One of the code blocks is

<svg xmlns=""
     viewBox="0 0 30 20"
I've tried variations like onload, on-load, onLoad etc in case reagent/hiccup was doing something in between, but haven't had success so far


A fast googling shows that there were problems with onLoad for svg in react.


React doesn't necessarily support all dom events


Anyway, it is probably good idea to lookup similar example for React and adapt that to Reagent. The example manipulates DOM directly which is not good fit for React.

Alexander Knemeyer12:09:46

Yeah, I think we found the same threads re react. It was from 2017 or so, so I thought I'd check just in case. Thanks, will look up a react example instead. I appreciate the help!