This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-04
Channels
- # announcements (19)
- # babashka (11)
- # babashka-sci-dev (9)
- # beginners (71)
- # calva (25)
- # cider (1)
- # clara (36)
- # clj-kondo (47)
- # clojure (65)
- # clojure-dev (64)
- # clojure-europe (9)
- # clojure-nl (2)
- # clojure-seattle (1)
- # clojure-uk (2)
- # clojured (8)
- # clojurescript (17)
- # cursive (9)
- # data-science (36)
- # datahike (11)
- # emacs (10)
- # figwheel-main (19)
- # fulcro (15)
- # graalvm (12)
- # humbleui (5)
- # introduce-yourself (3)
- # jobs (10)
- # leiningen (4)
- # lsp (24)
- # malli (7)
- # nextjournal (23)
- # off-topic (1)
- # pedestal (2)
- # polylith (6)
- # portal (1)
- # re-frame (3)
- # reitit (2)
- # releases (2)
- # remote-jobs (1)
- # reveal (9)
- # shadow-cljs (13)
- # spacemacs (6)
- # xtdb (3)
I have a custom component but it doesn't let me use custom events, i.e.:
(defn tab-context [attrs & children]
(when-let [on-foo (:on-foo attrs)]
(on-foo)))
[:div
[tab-context {:on-foo #(dipatch [:foo])}]]
it won't let me do it. First, it would try to convert on-foo
to onFoo
and complain "unknown event handler property". Okay, let's rename it. But even if I rename it, React still complains: "Invalid value for prop foo-handler
on <div> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM."
So have do I do this?More of a #reagent question.
The error about <div>
suggests that you set those attribute on a :div
somewhere. Simply extract the attributes for the :div
under its own key - exactly the way re-com does it with :attr
.
Also, don't call functions on render, unless you're absolutely certain that's the thing that must be done. Instead, use a form-3 component with the right :component-did-mount
and maybe :component-did-update
.