4

I need to display an input element with an initial value read from a cursor, but I don't need to update the cursor back when the user enters the new text. For example:

(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 have to provide a function to the onChange event in order to let the input element update itself, at least an empty one. Is this the proper way to do this? Many thanks.

roboli
  • 1,220
  • 16
  • 24

1 Answers1

2

Use :defaultValue instead of :value.

Thanks to this answer here

roboli
  • 1,220
  • 16
  • 24
  • 1
    For more information, this page in [React Documentation](https://facebook.github.io/react/docs/forms.html#uncontrolled-components) is good reading. – prabhasp Apr 19 '15 at 03:39