This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-11
Channels
- # announcements (2)
- # asami (1)
- # babashka (15)
- # beginners (29)
- # calva (6)
- # cider (22)
- # clara (1)
- # cljfx (1)
- # clojure (86)
- # clojure-australia (1)
- # clojure-dev (25)
- # clojure-europe (38)
- # clojure-france (7)
- # clojure-italy (3)
- # clojure-losangeles (1)
- # clojure-nl (6)
- # clojure-seattle (1)
- # clojure-spec (9)
- # clojure-uk (25)
- # clojuredesign-podcast (2)
- # clojurescript (4)
- # conjure (9)
- # cryogen (8)
- # cursive (17)
- # data-science (5)
- # datalog (1)
- # deps-new (1)
- # depstar (1)
- # emacs (1)
- # events (6)
- # fulcro (2)
- # graphql (3)
- # helix (4)
- # jackdaw (1)
- # jobs (1)
- # kaocha (9)
- # leiningen (4)
- # malli (1)
- # off-topic (7)
- # other-lisps (2)
- # pathom (12)
- # re-frame (16)
- # remote-jobs (1)
- # shadow-cljs (28)
- # spacemacs (19)
- # sql (2)
- # test200 (2)
- # testing (5)
- # timbre (1)
- # tools-deps (18)
- # xtdb (10)
@lilactown How do you pass parameter to the reducer function besides the action ?
i'm not sure what you mean yet. the reducer function signature is:
(fn [state action] ,,,)
example:
(defn my-reducer
[state action]
(case (:type action)
:foo (update state :foo inc)
:bar (update state :bar inc)))
(defnc my-component
(let [[state dispatch] (hooks/use-reducer my-reducer {:foo 0 :bar 0})]
(d/div
(d/div "Foo: " (d/button {:on-click #(dispatch {:type :foo})} (:foo state)))
(d/div "Bar: " (d/button {:on-click #(dispatch {:type :bar})} (:bar state))))))
👍 3
The action can by any value. As in the example a map which can also contain “parameters” besides the “action”.
👍 3