This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-19
Channels
- # beginners (134)
- # boot (4)
- # cider (23)
- # clara (2)
- # cljs-dev (2)
- # cljsrn (4)
- # clojure (147)
- # clojure-austin (9)
- # clojure-berlin (2)
- # clojure-dusseldorf (2)
- # clojure-france (2)
- # clojure-italy (11)
- # clojure-russia (1)
- # clojure-spec (18)
- # clojure-uk (182)
- # clojurescript (40)
- # community-development (5)
- # cursive (29)
- # datascript (6)
- # datomic (18)
- # duct (6)
- # emacs (4)
- # events (1)
- # fulcro (46)
- # hoplon (5)
- # jobs-discuss (12)
- # keechma (1)
- # luminus (7)
- # lumo (1)
- # off-topic (11)
- # onyx (9)
- # parinfer (5)
- # protorepl (1)
- # re-frame (18)
- # reagent (23)
- # reitit (2)
- # ring (5)
- # ring-swagger (20)
- # schema (1)
- # shadow-cljs (32)
- # spacemacs (1)
- # specter (2)
- # vim (26)
Does anyone have a good example of how to add a form-input into a form based on user-actions?
You can just wrap the optional input in an if-expression that checks the value from the other input
@c09mld - Of course i have no idea how to get the value from the other input either... I have some code I wrote a couple of months ago I can refer to though...
I realise that i have no idea how to interrogate the DOM from inside Reagent... Man i have got to stop adopting tools that I only partly understand based on the apparent utility of a couple of online tutorials... Don't get me wrong I really like what Reagent was able to do for me in terms of getting a very slick app up and running very quickly for a proof of concept / prototype, late on last year, but I'm starting to realise that I really need to understand it a lot better and I can't put it down for two months and expect to be able to just pick it up again... 😞
@maleghast I don't really know anything about javascript/the DOM, but I put together a survey form system last week, and I just put my data into clojure datastructures using the onchange attribute and then queried that, but there's probably a more direct way of doing it.
@c09mld - Honestly, based on discussions elsewhere, this does seem to be the "received" way of working with Reagent. I was just hoping that I could avoid "polluting" my app-state with state information about my form, as it feels icky to have display state data in amongst the domain/app data, but I guess that's what I need to do to get the result I want 🙂
A common pattern is to use a local reagent/atom in your form component for state that is truly local to only that component.
Check out "form-2 component" here: https://github.com/reagent-project/reagent/blob/master/docs/CreatingReagentComponents.md
The reagent todomvc example makes use of this https://github.com/reagent-project/reagent/blob/master/examples/todomvc/src/todomvc/core.cljs
Does anyone have any experience sharing a ratom between Reagent and Om? We have an older codebase using Om, and would like to transition to Reagent while sharing the same source of truth
@kingmob not sure if you can mix then But you can use om-next components in reagent For examploe
(defui Foo
[this]
(let [{:keys [count]} (om/props this)]
(dom/div nil count)))
(def ui-foo (om/factory Foo))
(def ratom (r/atom {:count 42}))
(defn reagent-stuff
[]
[:div
[ui-foo @ratom]
[:button {:on-click #(swap! ratom update :count inc)} "+"]])
Thanks. Our version is original Om, though.
OK, I might try that then. Thx!
Please feedback me 😄
I'm on oposite direction, I'm planning to write om
components in my re-frame app and at the end, switch the "state management".
Well, based on some sample tests from yesterday, it appears Om can use a ratom ok. Wouldn’t be surprised if there were some weird edge cases, tho