the-road-to-learn-react / use-custom-element

Custom hook to bridge Custom Elements (Web Components) to React.
https://www.robinwieruch.de
MIT License
90 stars 7 forks source link

Support for function callbacks as properties #9

Open kurienzach opened 5 years ago

kurienzach commented 5 years ago

First of all kudos to the awesome work.

In the organization that I work for, we have a widget library developed as LitElements. We don't use events much but use functions as properties inside the LitComponent. Currently, this code assumes that all props which are functions should be event handlers. But in our case, some functions need to be set as properties.

jimthedev commented 4 years ago

Hey @kurienzach!

I am working on a different (albeit similar) hook was wondering how you would like to make the distinction between functions that you want added as a handler and those that you just want as a prop.

Just to give an example, Angular will generally create a handler if you use (mouseleave) but not if you use mouseleave (it passes it through as a prop).

Initially I was thinking you could use a pattern like onMouseLeave (on followed by uppercase) to mean you want a handler and anything else, like mouseLeave to be a prop. Would that work?