bitovi / react-to-web-component

Convert react components to native Web Components. Works with Preact too!
https://www.bitovi.com/open-source/react-to-web-component
MIT License
728 stars 43 forks source link

Why did you declare this code within the plugin? #168

Open twoshlove opened 10 months ago

twoshlove commented 10 months ago

Why did you declare this code within the plugin? I don't understand why ReactWebComponent.prototype.prop is defined because attributeChangedCallback seems to handle it correctly.

Object.defineProperty(ReactWebComponent.prototype, prop, {
  ....
}
justinbmeyer commented 10 months ago

It's nice to be able to change the properties of the element directly. It's also the best way of sending data in the heap.

const someData = makeSomeData();

customElement = new MyCustomElementBuiltFromReact2WC();
customElement.data = someData;
twoshlove commented 10 months ago

@justinbmeyer Thanks for the kind explanation