Preact: Use of onInput in docs

Created on 28 Oct 2016  路  8Comments  路  Source: preactjs/preact

https://preactjs.com/guide/linked-state#linked-state-to-the-rescue

onInput is used to update state, but https://facebook.github.io/react/docs/forms.html recommends avoiding onInput and using onChange instead. Might be worth changing to onChange or adding a note to explain why onInput should be used despite React's advice.

beginner-friendly documentation

Most helpful comment

Good point, it's definitely a little under-explained. onInput is used because preact doesn't change the behavior of the DOM onchange event like React does. Instead, it encourages using the existing browser events under their existing names.

All 8 comments

Good point, it's definitely a little under-explained. onInput is used because preact doesn't change the behavior of the DOM onchange event like React does. Instead, it encourages using the existing browser events under their existing names.

A footnote in the "Differences to React" section might help clarify this. https://github.com/pl12133/preact-www/commit/ffa906b704cf52ee39d3a3d705d3188b0cf39de7

@pl12133's change is published, but I think it might be worth adding a blurb to the Linked State page abount onInput as well.

Not sure I entirely understand鈥攊s this is a breaking change when switching from React? (e.g. if a user relies on behavior of onChange events, does this break?) If so would kindly suggest also adding a line about this under the Switching to Preact page :)

Only if you're switching from React to Preact itself.
If you're using preact-compat, onChange behaves the same as React's.

What should be done here ? Update the Switching to Preact page ?

I think we can safely close this. On https://preactjs.com/guide/differences-to-react we have a section about relying on native events and not using an abstraction like react does.

@marvinhagemeister: which section is that? The "Synthetic Events" bullet under "What's missing?"?

I think that should be expanded upon, at least to recommend using onInput instead of onChange.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KnisterPeter picture KnisterPeter  路  3Comments

kay-is picture kay-is  路  3Comments

jescalan picture jescalan  路  3Comments

k15a picture k15a  路  3Comments

kossnocorp picture kossnocorp  路  3Comments