Fork me on GitHub
#reagent
<
2019-06-18
>
metehan07:06:27

i am a newbie here

metehan07:06:40

can someone tell me what i am doing wrong here:

metehan07:06:24

i can read the value and print but this :on-click swap doesn't work

metehan09:06:23

swap is working but it doesn't change the value the input

metehan09:06:08

so maybe reagent doesn't render the changes ?

orestis09:06:00

I usually put a js/console.log at the top-level to see if something is actually re-rendering and what’s going on

aisamu09:06:51

@m373h4n you're defining the r/atom at the render level, so your changes will be lost on the re-render. Quickest fix is to change the let to an r/with-let, so that the bindings are defined once at the "mount" phase. You can also use a form-2 component, returning a render function that closes over the r/atom

aisamu09:06:23

(defn login []
  (r/with-let [values (r/atom {:email 
(defn login []
  (let [values values (r/atom {:email ...})]
    (fn []
      [layout ... 

metehan09:06:24

woo thanks

metehan09:06:11

is there any "best way" between two mehods

Mno09:06:47

I believe the standard is form-2, or at least I've seen it more often.

metehan10:06:29

thank you Mno

metehan10:06:51

i'll go with second form