Editing Om input correctly with set: value

I need to display an input element with an initial value read with the cursor, but I do not need to update the cursor when the user enters new text. For instance:

(defn my-comp [app owner]
  (reify
    om/IRender
    (render [_]
      (dom/div nil
               (dom/label nil "Enter text: ")
               (dom/input #js {:value (:text app)
                               :onChange #()}))))) ;; <- Why do I still need this?

I found that I always need to provide a function for the onChange event to allow the input element itself to be at least empty. Is this the right way to do this? Many thanks.

+4
source share
1 answer

Use: defaultValue instead of: value.

Thanks to this answer here

+2
source

Source: https://habr.com/ru/post/1542695/


All Articles