Quantcast
Viewing latest article 35
Browse Latest Browse All 45

Answer by Rei Miyasaka for Fable.React - editing an Input field moves cursor to end of text

Use Fable.React.Helpers.valueOrDefault instead of DefaultValue or Value:

/// `Ref` callback that sets the value of an input textbox after DOM element is created.// Can be used instead of `DefaultValue` and `Value` props to override input box value.let inline valueOrDefault value =        Ref <| (fun e -> if e |> isNull |> not && !!e?value <> !!value then e?value <- !!value)

Maximillian points out in his answer that it's because React is recreating the DOM object. In my attempt to figure out how to use hooks to determine why, I ended up learning about React Hooks and about how to use them from Fable, but I never figured out how to use them to figure out what's causing the DOM object to be deleted.


Viewing latest article 35
Browse Latest Browse All 45

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>