Fork me on GitHub
#reagent
<
2018-02-26
>
theasp13:02:52

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.

justinlee16:02:02

@tkircsi Are you saying that the price updates but it isn’t formatted?

justinlee16:02:37

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)