@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))))))
The action can by any value. As in the example a map which can also contain “parameters” besides the “action”.