Fork me on GitHub
#reagent
<
2018-09-02
>
unwarysage22:09:42

Trying to make sense of something. I have followed the examples on the reagent site, for the text boxes that update an atom. but when I use them, the text boxes do not accept input. This is really basic probably, but I can't find a good search term.

unwarysage22:09:08

Anyone have any advice?

gadfly36122:09:46

@shawx538 can you show a code snippet of what you are trying

unwarysage22:09:26

@gadfly361

(defn about-page []
  (let [small-example (reagent/atom "Sandford")]
    [:div
       [:input {:type "text"
                :value @small-example
                :on-change #(reset! small-example (-> % .-target .-value))}]
       [:h1 @small-example]]))

unwarysage22:09:10

This is a test piece of code, trying to get any text input to work

gadfly36122:09:35

The problem is you're making a reagent atom inside the render function, so it is recreated every render .. you need to use a form-2 component... Take a look at link I sent you, goes over this exact problem

unwarysage22:09:23

double thanks for this cookbook repo. This is great

🍻 4