Fork me on GitHub
#reagent
<
2020-08-08
>
quadron22:08:15

I have the following reagent component. if i remove the random-uuid i get warnings and if i add them, the input field loses focus after entering a single character! what is going on here? can somebody please help me?

(defn input-fields
  []
  [:div
   [:div.h1
    [:p (str "content of states: " @state)]
    [:p "fuck you"]]
   (doall
    (for [id (range 5)]
      [:div #_{:key (random-uuid)}
       [:input {
                :type :text
                :value #_(:foo @state)
                (sp/select-one [sp/ATOM :input sp/ALL #(= (:id %) id) :attribute] state)
                :on-change (fn [e]
                             (sp/transform [sp/ATOM :input sp/ALL #(= (:id %) id)]
                                           (fn[x] (assoc x :attribute (-> e .-target .-value))) state))}]
       [:input {
                :type :text
                :value #_(:foo @state)
                (sp/select-one [sp/ATOM :input sp/ALL #(= (:id %) id) :value] state)
                :on-change (fn [e]
                             (sp/transform [sp/ATOM :input sp/ALL #(= (:id %) id)]
                                           (fn[x] (assoc x :value (-> e .-target .-value))) state))}]]))
   [:input {
            :type :button
            :value :submit
            :on-click (fn [e]
                        (println "submit placeholder"))}]])