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?
Maybe something like this: https://github.com/rockiger/re-natal-tutorial/blob/handling_text_input/src/re_natal_tutorial/ios/core.cljs#L16
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
Do you a form-2 component ? https://github.com/reagent-project/reagent/blob/master/doc/CreatingReagentComponents.md#form-2--a-function-returning-a-function
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))}]])))
right, the penny dropped, that is what I wanted, thanks