Fork me on GitHub

Hi all! I'm trying to render a TextInput with an initial value. If I set the :value prop it becomes uneditable. googling tells me I should also do onChangeText={text => this.setState({ text })} but I don't see how to translate that to cljs. I'm in a re-frame function that returns hiccup. Do any of you have an example of how to use this-as for a react component?


in this case, it's the value I'd like to change, the placeholder disappears when the user edits. I'm showing an invalid input and asking the user to update that value

Michaël Salihi12:03:38

Here a simple eg. with input local state

(defn main-panel []
  (let [name (reagent.core/atom "Re-frame")]
    (fn []
       [:h1 "Hello from " @name]
       [:input {:value @name
                :on-change #(reset! name (.. % -target -value))}]])))


right, the penny dropped, that is what I wanted, thanks

👍 8