This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-22
Channels
- # announcements (11)
- # babashka (4)
- # beginners (98)
- # calva (18)
- # chlorine-clover (1)
- # cider (44)
- # clj-kondo (6)
- # clojure (61)
- # clojure-australia (4)
- # clojure-dev (4)
- # clojure-europe (132)
- # clojure-italy (5)
- # clojure-nl (4)
- # clojure-uk (31)
- # clojurescript (40)
- # community-development (8)
- # conjure (20)
- # data-science (1)
- # datomic (42)
- # defnpodcast (6)
- # emacs (3)
- # events (1)
- # fulcro (9)
- # graphql (2)
- # hugsql (1)
- # jobs (1)
- # malli (4)
- # off-topic (28)
- # pathom (27)
- # rdf (1)
- # re-frame (10)
- # reagent (4)
- # remote-jobs (1)
- # reveal (32)
- # sci (5)
- # shadow-cljs (18)
- # spacemacs (1)
- # tools-deps (62)
- # xtdb (4)
Hi everyone, I'm trying to make an input field that switches classes depending on whether it's focused or blurred. In the simple example below I noticed that the focused
value never changes despite the on-click
handler. Any advice would be appreciated!
(defn editable-field [config]
(t/let-spy [is-focused (r/atom false)
set-focused #(reset! is-focused true)
set-blurred #(reset! is-focused false)
focused (if @is-focused "input-focused" "input-blurred")
editable-config (merge config
{:on-click set-focused
:on-blur set-blurred})]
[:div
[:input editable-config]
focused]))
But the problem is that your atom is redefined on render, you need to use form-2 component here. https://purelyfunctional.tv/guide/reagent/#form-2
🙏 3