Skip to content

Instantly share code, notes, and snippets.

@alexslade
Last active August 29, 2015 14:12
Show Gist options
  • Save alexslade/d74b8cafa1fda0452fe5 to your computer and use it in GitHub Desktop.
Save alexslade/d74b8cafa1fda0452fe5 to your computer and use it in GitHub Desktop.
(defn new-contact []
(let [val (r/atom "")]
(fn []
[:div
[:input {:type "text"
:value @val
:on-change #(reset! val (-> % .-target .-value))}]])))
; Works fine
(defn update-input [input]
(reset! val (-> input .-target .-value)))
(defn new-contact []
(let [val (r/atom "")]
(fn []
[:div
[:input {:type "text"
:value @val
:on-change update-input}]])))
; Gives error:
; Uncaught Error: No protocol method IReset.-reset! defined for type function: function val(map_entry){
; return cljs.core._val.call(null,map_entry); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment