Code Monkey home page Code Monkey logo

Comments (6)

MangelMaxime avatar MangelMaxime commented on August 20, 2024

Future version of Elmish will have a better naming for withReact so I don't think adding these specials handlers is needed.

See https://github.com/elmish/react/pull/31/files

Also, if people are using Prop.Ref to add a special behavior to their input or textarea your code will override this behavior and make it hard for them to understand the source of the bug.

from fable-react.

chadunit avatar chadunit commented on August 20, 2024

What bug do you mean? The user's Ref callback is still called. Plus this is a quick prototype to explore the idea, code can still be improved or warnings/hints added, etc.

I think this wouldn't add any more user difficulty than the status quo which has been accepted up to present.

Compare:

  1. Some number of users encounter common issue with cursor.
  2. Search web site/github for cursor issues.
  3. Learn about performance optimization affecting cursor in withReactBatched, and get alternatives.

vs:

  1. Presumably much smaller number of users encounter unknown edge case issue with Ref.
  2. Search web site/github for Ref issues.
  3. Learn about usability optimization using Ref internally in the input helper, and get alternatives.

I support the new names but they mostly improve understanding of the issue vs. avoiding the issue in the first place. Especially if templates/samples/etc. just switch over to withReactBatched, which the obsolete tag for withReact will recommend, then new user experience will be essentially the same but with improved names.

from fable-react.

MangelMaxime avatar MangelMaxime commented on August 20, 2024

Hum sorry I didn't saw the updateValueIfDifferent and was thing you were loosing the user ref function.

I am not sure what to think about this but as long as it's provide as input' and textarea' (not made the default) I am ok for the change.

from fable-react.

chadunit avatar chadunit commented on August 20, 2024

I don't think there is much value adding them as non-default. Then they just become yet another workaround in a list of several workarounds already. I want to eliminate the need for workarounds for the majority of users, not add another one to their decision tree.

from fable-react.

alfonsogarciacaro avatar alfonsogarciacaro commented on August 20, 2024

This is great work @chadunit, thank you! Only thing is, as Maxime says, we're trying to introduce as less magic as possible in the bindings. We do it for example with the prop lists to have more idiomatic F# code, but this already confuses some users (see #132). When the function doesn't correspond 1:1 to React, I like to change the name to avoid this (example).

I'd wait a bit to see if the new names in Elmish.React help people be aware of the error. If it's still happening we can revisit this and implement the patches :)

from fable-react.

chadunit avatar chadunit commented on August 20, 2024

If changed names are the only option then perhaps this:

/// An input element with an automatic internal Ref prop to maintain cursor position when Value matches DOM state.
let inputRefCursor props =
  createElement("input", props |> convertValueToRef |> keyValueList CaseRules.LowerFirst, [])

/// A textarea element with an automatic internal Ref prop to maintain cursor position when Value matches DOM state.
let textareaRefCursor props children =
  createElement("textarea", props |> convertValueToRef |> keyValueList CaseRules.LowerFirst, children)

But anyway will go ahead and close for now, to await resurrection if revisted later.

from fable-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.