This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-20
Channels
- # aleph (1)
- # announcements (1)
- # aws (11)
- # babashka (117)
- # beginners (34)
- # calva (13)
- # cider (3)
- # clj-commons (8)
- # clj-kondo (24)
- # clj-yaml (36)
- # cljsrn (46)
- # clojure (50)
- # clojure-australia (5)
- # clojure-europe (239)
- # clojure-nl (3)
- # clojure-norway (3)
- # clojure-spec (16)
- # clojurescript (25)
- # core-typed (20)
- # cursive (41)
- # datahike (1)
- # datalevin (1)
- # datomic (17)
- # fulcro (27)
- # hyperfiddle (35)
- # introduce-yourself (1)
- # jobs (4)
- # lsp (20)
- # malli (8)
- # meander (8)
- # nbb (1)
- # off-topic (31)
- # parinfer (9)
- # pathom (3)
- # portal (2)
- # re-frame (20)
- # react (2)
- # reagent (8)
- # releases (1)
- # remote-jobs (4)
- # scittle (2)
- # shadow-cljs (8)
- # slack-help (4)
- # sql (30)
- # squint (3)
- # tools-deps (34)
- # xtdb (21)
I have a radio button defined and one of teh item value is selected by default , My functionality is working as expected for on-change, But how can i call dispatch function for default checked item ?
{:id value
:key key
:name-const id
:type "radio"
:default-checked selected
:value value
:on-change #(dispatch :user-selects-item id (-> % .-target .-value))}
initially , by default few values are inserted it to db, and in the function, when item matches in the list, by default radio button will be checked for that item
From re-frame's perspective, there should not be any dispatch
here at all when you just display that radio button for the first time. You already have all the necessary data in the app-db, and absolutely everything else in your app should be a consequence of a direct user action (or some background activity, like js/setTimeout
and whatnot) given a particular app-db state.
Clicking a button is a direct action, loading the app is a direct action. But something being rendered because or some action is not a direct action by itself.
Something has led to that radio button being shown in its particular state. That very "something" is responsible for all the initial processes.
Ah, here's a proper doc on the topic: https://day8.github.io/re-frame/FAQs/LoadOnMount/
oh I did one more thing now!!! I surrounded my radio component in a fn like below
` (defn hello []
(dispatch-intial load)
(fn []
{:id value
:key key
:name-const id
:type "radio"
:default-checked selected
:value value
:on-change #(dispatch :user-selects-item id (-> % .-target .-value))}))