This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-11-21
Channels
- # announcements (1)
- # babashka (66)
- # beginners (37)
- # calva (3)
- # cljdoc (2)
- # clojure (14)
- # clojure-australia (6)
- # clojure-doc (4)
- # clojure-europe (22)
- # clojurescript (9)
- # datalevin (5)
- # datomic (4)
- # emacs (5)
- # events (1)
- # figwheel-main (6)
- # graalvm (41)
- # lsp (16)
- # luminus (1)
- # off-topic (2)
- # overtone (2)
- # re-frame (2)
- # reagent (8)
- # remote-jobs (1)
- # reveal (49)
- # shadow-cljs (9)
- # spacemacs (14)
- # tools-build (4)
- # tools-deps (16)
Hi all! I’m working with a library with an unavoidably-imperative API (https://github.com/0xfe/vexflow/wiki/Tutorial 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?
Hi there, I want to handle some key events, so I have found the following lib https://github.com/gadfly361/re-pressed But, while I have called both
(re-frame/dispatch-sync [::rp/add-keyboard-event-listener "keydown"])
(re-frame/dispatch
[::rp/set-keydown-rules
{: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 channelMake sure your browser doesn't consume the keys (via plugins etc). This bites me all the time
The spacebar has a default function in the browser that needs to be overridden. Re-pressed has a special way of handling these: https://github.com/porkostomus/typing/blob/9bf7f3f5be4aa867593a70b5287d5f29e97a95d2/src/typing/views.cljs#L77
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 🙂