Fork me on GitHub

Hi all! I’m working with a library with an unavoidably-imperative API ( for those interested). So far, my approach to functionalizing it is to pass a data structure describing what I want rendered to a react component. With vanilla react I’d use a combination of refs and useEffect to imperatively render the data. Refs are straightforward enough with reagent, but I’m not sure what the equivalent of useEffect is. Is there an easy way to run some code after every render without going all the way into a form-3 component? Or should I switch to a functional component?

🎶 1

you should use a form 3 component or a functional component


Hi there, I want to handle some key events, so I have found the following lib But, while I have called both

(re-frame/dispatch-sync [::rp/add-keyboard-event-listener "keydown"]) 

        {:event-keys [[[::key-events/spacebar-pressed]
                     [{:keyCode 32}]]}])
My event ::key-events/spacebar-pressed is never called. I can see from the re-frame-10x that in the event-history tab the :re-pressed.core/set-keydown-rules event is called, but no luck when I press the spacebar Any thoughts? Maybe my question is fit better to the re-frame channel, but on lib's GitHub page, author @gadfly361 says for any questions he can be found at reagent channel


Make sure your browser doesn't consume the keys (via plugins etc). This bites me all the time

Bobbi Towers01:11:32

The spacebar has a default function in the browser that needs to be overridden. Re-pressed has a special way of handling these:

👍 1

It has been a while for me, but if the browser is swallowing the key then I would try @U8LB00QMD suggestion 👍


Hmm ok guys thanks you, will try the prevent-default-keys and let you know 🙂


I'm a little bit late, but.. It worked! Thank you guys!

👍 2