choojs / nanocomponent-adapters

🔌 - Convert a nanocomponent to a component for your favourite API or library (web components, (p)react, angular)
MIT License
96 stars 17 forks source link

Update adapters #12

Closed bcomnes closed 7 years ago

bcomnes commented 7 years ago

I had to remove the custom element one because it didn’t work and I don’t have time to fix it. Please, someone add this back!

bcomnes commented 7 years ago

These are also minimally untested. Good luck!

timwis commented 7 years ago

@bcomnes I may be wrong here, but the way I'm reading the react adapter, it would only work for one use, i.e.

var ReactButton = toReact(Button, react)
ReactDOM.render(<ReactButton />, node) // works
ReactDOM.render(<div><ReactButton /><ReactButton /></div>, node) // what about this?

My guess is that it would be using the same nanocomponent instance, and sharing props, node, etc. as well. Forgive me for not just trying it but I'm on-the-go and wanted to point this out in case it's time-sensitive.

Perhaps the solution (if this indeed a problem) is to put things like var comp = new Component() inside react's constructor method?

bcomnes commented 7 years ago

I was looking at that too, and I believe you are right, although this problems appears to be an issue with the existing version as well.

bcomnes commented 7 years ago

Going to merge this for now. I think I addressed @timwis's points. I want to revisit the Preact and Angular 2 example: https://github.com/choojs/nanocomponent-adapters/pull/6 soonish

bcomnes commented 7 years ago

I'll release these as 2.0.0 and we can iterate with patches and minor bumps for a bit.