Fork me on GitHub
#cljsrn
<
2020-03-11
>
wonko711:03:30

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?

wonko711:03:34

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 []
      [:div
       [:h1 "Hello from " @name]
       [:input {:value @name
                :on-change #(reset! name (.. % -target -value))}]])))

wonko713:03:42

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

👍 8