devongovett / svelte-hooks

50 stars 3 forks source link

Make it work for both 'on:change' and 'onChange' props #9

Open TylerRick opened 3 years ago

TylerRick commented 3 years ago

Looks like https://svelte.dev/repl/f4b5f661bb7b40b7bd1272c1f58d2efc?version=3.24.1 supports 'on:change' style but this one supports 'onChange' style.

It would be nice if you could supply it in either format and it would work...

TylerRick commented 3 years ago

I can see why you would want to support the onChange style — for compatibility with props coming from libraries written more with React in mind, like how you did in https://github.com/devongovett/svelte-hooks/blob/master/Button.svelte with props coming from:

import {useButton} from '@react-aria/button';
({buttonProps, isPressed} = useButton({onPress}));

but when using this with props supplied from a native Svelte-only app, the onChange style is not idiomatic, and it seems the on:change style would be preferable (idiomatic for Svelte).