This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-26
Channels
- # aleph (2)
- # aws-lambda (18)
- # beginners (81)
- # boot (3)
- # cider (25)
- # cljs-dev (274)
- # cljsjs (10)
- # clojars (25)
- # clojure (65)
- # clojure-austin (1)
- # clojure-brasil (2)
- # clojure-dev (33)
- # clojure-dusseldorf (6)
- # clojure-gamedev (3)
- # clojure-italy (17)
- # clojure-poland (3)
- # clojure-russia (7)
- # clojure-spec (48)
- # clojure-uk (45)
- # clojured (1)
- # clojurescript (26)
- # core-logic (2)
- # data-science (4)
- # datascript (6)
- # datomic (58)
- # defnpodcast (2)
- # docker (1)
- # duct (14)
- # figwheel (2)
- # fulcro (130)
- # graphql (3)
- # leiningen (1)
- # liberator (15)
- # luminus (5)
- # nrepl (1)
- # numerical-computing (1)
- # off-topic (45)
- # onyx (15)
- # re-frame (9)
- # reagent (3)
- # ring (1)
- # shadow-cljs (91)
- # spacemacs (8)
- # sql (23)
- # unrepl (38)
- # videos (2)
- # vim (12)
I'm just speculating, but could it be that regent/react won't update :value of an input box if you had interacted with it? I would imagine that one atom people would be annoyed with their form fields changing all the time.
also: a couple of tips to make this code less complex: (1) instead of passing the item by value on line 52, then creating local ratom for price on 14, you should pass a reagent/cursor
to the shopping-item
component like so [shopping-item (reagent/cursor shoppinglist [(:id item)])]
. Then you can just update the cursor and your main state atom will get updated automatically. (2) if you don’t want to do that, you can rewrite (update-item! assoc id (assoc {} :id id :name name :price (js/parseInt @rprice)))
like this (update-item! assoc-in [id :price] (js/parseInt @rprice))
— generally speaking get-in
and assoc-in
make dealing with nested data easier (and eventually you might want to graduate to the specter library, though there’s a little bit of a ramp-up to learn how to use it)