Skip to content

Instantly share code, notes, and snippets.

@davidbalbert
Created July 7, 2014 01:57
Show Gist options
  • Save davidbalbert/33b4d44cd9da2dff1ae0 to your computer and use it in GitHub Desktop.
Save davidbalbert/33b4d44cd9da2dff1ae0 to your computer and use it in GitHub Desktop.
A curious case.
(def hmm-state (atom {:value "Hmm..."}))
(defn hmm [state owner]
(reify
om/IRender
(render [_]
(om.dom/textarea #js {:value (:value state)
:onChange (fn [e] (.log js/console (.. e -target -value)))}))))
(om/root
hmm
hmm-state
{:target (. js/document (getElementById "app"))})
@davidbalbert
Copy link
Author

Without the onChange handler, you can't change the value of the textarea because the textarea is controlled. This is what I would expect. When you add the onChange handler, you're able to change the value of the textarea even though the onChange handler doesn't update the app state, effectively making the textarea uncontrolled (or at least act like it's uncontrolled). Why is this?

@davidbalbert
Copy link
Author

This is with Om 0.6.4 and ClojureScript 2268.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment