zouhir / preact-habitat

Zero configuration Preact widgets renderer in any host DOM
MIT License
518 stars 43 forks source link

Add support for global access to the widget by passing ref #49

Closed reznord closed 1 year ago

reznord commented 3 years ago

Right now there is no way to access the widget from the global scope. For eg: if I want to access the widget on a global scope (window.widget.foo()) it is not possible till now because it wasn't possible to add a reference on the widget level.

This PR adds support for adding ref to the component itself.

bumi commented 3 years ago

I like that this makes the widget accessible to programatically control it.

would it be possible to somehow return the object by the .render function? This would allow to have multiple widgets on the same page and make all of those accessible.

let myWidget = _habitat.render({...}); 
bumi commented 3 years ago

do you think this can make it in master? would be super helpful. //cc @zouhir

bumi commented 3 years ago

@zouhir friendly ping. do you think this could make it in a release?

bumi commented 3 years ago

hey @zouhir that's nice. Though I think I am not a very good maintainer for the library as I know too little about preact and the details of this library. I think @reznord is the right person to support!! <3