Fork me on GitHub
#reagent
<
2015-09-22
>
vorob17:09:51

Does anybody know why input won’t change itself if I remove fn [] ?

(defn new-contact []
  (let [val (r/atom "")]
    (fn []
      [:div
       [:input {:type "text"
                :placeholder "Contact Name"
                :value @val
                :on-change #(reset! val (-> % .-target .-value))}]
       [:button {:on-click #(when-let [c (parse-contact @val)]
                              (add-contact! c)
                              (reset! val ""))}
        "Add"]])))

gadfly36117:09:40

Look at foo-mistake

vorob17:09:29

@roberto: @gadfly361 💞💞💞💞💞

erik_price20:09:26

@roberto, qq about that document you linked to: exactly what gets passed to the inner function (the renderer function) on re-renders? I understand about the renderer function closing over the values passed to the outer function, but… I’m confused about what is actually passed to a renderer function.

roberto20:09:01

whatever you specify in the (fn []) as an argument

roberto20:09:45

(defn a-view [p1 p2]
   (fn [p1 p2]
      ….))

roberto20:09:21

or

(defn a-view
    []
   (let [p1 (something)]
    (fn [p1]
        ….)))

seancorfield21:09:06

Don’t the outer and inner functions need to have the same number of arguments?

seancorfield21:09:50

Did you mean (defn a-view [] (let [p1 (something)] (fn [] … p1 …))) ?